How to execute a .vbs file in a linux OS from java - java

I have a .vbs file that makes the conversion of a docx file to a pdf type file, i run this .vbs from java in windows. Since i need this program running in a linux based OS i don't know if this solution would work.
the .vbs and the java code that i use for the project is here in this link: http://mydailyjava.blogspot.mx/2013/05/converting-microsoft-doc-or-docx-files.html
Note: I tried other solutions to convert the docx file to a pdf, but these solutions (docx4j, xdocreports, jodConverter) causes loss of format in the final pdf file, so those apis are not an option.

It is unlikely that you would be able to run the mentionned programs on Linux, since for that you would need:
Microsoft Word installed, to open the Word file and print it
Microsoft scripting host, to execute the vbs script
A batch script interpreter that can access the scripting host
Since all these items are Microsoft software, they don't run natively on Linux.
So you will have to find alternatives as suggested by vzamanillo, or maybe find a way to run this in a WINE environment, but then that's not really Linux.

Since you're doing this from java, if you are open to using 3rd party software you could try jWordConvert.

Related

Converting a jar file to exe file

Setup
I am running on windows 10
Have python 3.6 and Java 8
description
I have a Java program which calls and passes an argument to a python program and then receives its output using system commands and cmd.
Question
How do I convert it into a single exe file that is the user can run it without installing java(jdk or jre) and python.
Both are a part of my system variable
Thank you
You can use launch4j application which can convert your jar to an .exe file.
Refer to this: https://www.programcreek.com/2009/05/convert-java-jar-file-to-exe/
Use pyinstaller to package the python file in a exe.
Then in the java program replace xyz.py with xyz.exe
Use JarToExe to convert the jar into a Windows .exe file.
This way you would have two exe files but the user would not need to install java or python

Opening Terminal from Java jar File

I am working on a project that requires an executable jar file but I still want the command line to show once it has been run. Is there a way to do this, or similar such as creating a new terminal window and execute the jar on that window.
I am fine with writing code for multiple operating systems.
Thanks for the help.
Since the terminal path for each OS is different, you should write the code for each OS. You can try following Java code.
Runtime.getRuntime().exec("/path/to/terminal");
For example, if it is Ubuntu, the code should be,
Runtime.getRuntime().exec("/usr/bin/gnome-terminal");
Further if you want to check the system OS and architecture, you can get them from System properties.
System.getProperty("os.name");
System.getProperty("os.version");
System.getProperty("os.arch");

How to execute Carrot2 Document Clustering server

I downloaded the Carrot2 Document clustering server build 3.15.0 for Mac. The read me file says:
The DCS requires a Java Runtime Environment (JRE) version 1.7.0 or later. To
run the DCS, execute the 'dcs' script and point your browser at
http://localhost:8080 for further instructions.
Mac OS Sierra doesn't make it easy, but I got 1.8.0_112 installed.
The problem is that I don't know how to execute the 'dcs' script.
There are .cmd, .sh, .war, and .jar files. I wasn't sure which of those to work with. I thought .jar looked promising, so I followed some of this thread and tried this in a terminal window:
java -jar invoker.jar
I cd-ed to the correct directory, but it just says Provide main class, but I'm not sure what or where that is.
Can anybody provide instructions or a link to how to do this?
Use the dcs.sh (on Linux/Mac) and dcs.cmd (on Windows) to start the server. The scripts will set some extra options for the JVM and then start the DCS. In case of any problems, append the -v option to see diagnostic output.

Running a project with shell commands

I need to open a project which I think it is written in linux or need linux env for building it.
I use Win8 and I'mnot familiar with Linux env anymore.
Iin it's README file, it is written s.th like this:
HOW TO INSTALL
> tar xzvf DepOE-beta.tar.gz
> sh install-DepOE.sh
Two NLP tools are installed:
- DepPattern (dependency-based parser)
- Tree-Tagger (PoS tagger)
Pay attention: do not install the package in a directory whose name contain blank spaces!
HOW TO USE
depOE.sh <tagger> <lang> <file> [parser]
tagger=freeling, treetagger
language=gl, es, en, pt, fr
file=path of the input file
I opened it by Eclipse env which is integrated with Perl. but I couldnt open it.
what should I do??
please help me:(
since the usage file specifically says that you need to run
depOE.sh <tagger> <lang> <file> [parser]
I believe you will need some sort of UNIX shell to make it work. Moreover from the file tree you posted I believe you will also need a running Perl implementation on your machine. Please refer to http://slu.livejournal.com/17395.html for a tutorial on how to install Cygwin and Perl for Windows. Cygwin should give you some basic Linux/Unix/GNU tools for Windows environments and Perl obviously is a Perl interpreter for Windows.
However, I believe in your case the option to run a real Linux operating system in a virtual environment (if you want to keep your Windows installation untouched) is the best way to go. The fastest way (and a free option) would be to download VirtualBox from https://www.virtualbox.org and a Linux VM for instance with Ubuntu preinstalled from here http://virtualboxes.org/images/ubuntu/.

Java | CSV issue with ^M

I have problem with this annoying ^M, while exporting some data, writing it to a CSV file to be downloaded. I did some research and found out that if the file you are reading comes from a Windows system this issue happens (Windows uses CR (i.e. ^M)/LF pair to indicate the end of a line, while UNIX uses only a LF).
Now can anyone offer me a solution to overcome this problem (like eliminating or replacing ^M ) before putting it to the writer (writer.write(columnToBeInserted);)
You could use unix2dos and dos2unix to convert UNIX and Windows files respectively. Both are available on *nix and Windows platforms. Read more.
Links for Windows
Dos2Unix
Unix2Dos
Also see How to convert files from Dos to Unix in java
As you read each line do
line.replaceAll("\\p{Cntrl}", "");
Or use a tool to do it for you
in linux/unix environment there is a utilities called dos2unix and unix2dos which converts the files from windows to linux format and vise versa .
on windows check this link and download the utility whch will convert from windows to linux format http://www.sg-chem.net/u2win/

Categories

Resources