run jar on mac with arguments - java

I have a bioinformatics related tool can be found here. The tool can be download from the link under that page.
It is a Java packaged files for which on Windows I can run
a compiled version (see the readme, need to change name of Mold2.doc to Mold2.exe) using the following command line:
Mold2 -i TestCompounds.sdf
(I have moved the TestCompounds.sdf file to same path as that exe)
It will produce some message and output 2 files output.txt and report.txt.
The trouble is that this package doesn't have any pre-compiled version executable for Mac OS.
However, since Java is supposedly cross-platform and since I also have the java Mold2.jar file, I think it would work for me if I can execute under Mac OS. But I can find the way how to do that...
I have tried with:
java -cp Mold2.jar Mold2
But it only invoke the GUI, and I can't find how to execute this program with only arguments under terminal without invoking the GUI, which is what I want is for integration purpose.
So how can I run this tool on Mac OS on terminal?

Related

Issue running tensorflow with java

I am having some issues running tensorflow with java. I am using CUDA 8 with CuDNN 6.
I tried following the quickstart instructions located here: https://www.tensorflow.org/install/install_java and get the following error message when I attempt to run the example java program:
java -cp libtensorflow-1.4.0.jar:. -Djava.library.path=./jni HelloTF
Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot find TensorFlow native library for OS: linux, architecture: x86_64. See https://github.com/tensorflow/tensorflow/tree/master/tensorflow/java/README.md for possible solutions (such as building the library from source). Additional information on attempts to find the native library can be obtained by adding org.tensorflow.NativeLibrary.DEBUG=1 to the system properties of the JVM.
at org.tensorflow.NativeLibrary.load(NativeLibrary.java:75)
at org.tensorflow.TensorFlow.init(TensorFlow.java:66)
at org.tensorflow.TensorFlow.<clinit>(TensorFlow.java:70)
at org.tensorflow.Graph.<clinit>(Graph.java:258)
at HelloTF.main(HelloTF.java:8)
The jni directory contains the following:
libtensorflow_framework.so
libtensorflow_jni.so
LICENSE
I then tried installing the binaries from source as suggested here:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/java/README.md
This is the output from setting: org.tensorflow.NativeLibrary.DEBUG=1
org.tensorflow.NativeLibrary: tryLoadLibraryFailed: /path/to/jni/libtensorflow_jni.so: libcublas.so.8.0: cannot open shared object file: No such file or directory
org.tensorflow.NativeLibrary: jniResourceName: org/tensorflow/native/linux-x86_64/libtensorflow_jni.so
org.tensorflow.NativeLibrary: frameworkResourceName: org/tensorflow/native/linux-x86_64/libtensorflow_framework.so
But I still get the same error message when I try and run the example Java program.
What am I doing wrong??
Any help would be greatly appreciated!
The error
Cannot find TensorFlow native library for OS: linux, architecture: x86_64.
is clearly stating that the library is not visible to your software.
To make it available to the Java class, try doing like that (in the same shell obviously):
export LD_LIBRARY_PATH=/the/absolute/path/to/your/library
java -cp libtensorflow-1.4.0.jar:. -Djava.library.path=./jni HelloTF
also ensure you're running the java command from the same directory which contains the /jni directory.
For those landing here and facing the same issue.
You are probably trying to run your program from eclipse. Then, you have to go to Run configurations > Arguments and pass this arguments:
Program arguments -> models/
images/example-400x288.jpg
VM Arguments -> -Djava.library.path=./jni
like in this screenshot:
When people (like myself) come from python to java world, everything is strange! here is how I solved my problem regarding all linking errors:
I assumed you already have simple hello Tensorflow project, explained here
Download and copy tensorflow JNI files to :/usr/lib/tensorflow
Download and copy desired version of tensorflow Lib jar file to: /usr/lib/tensorflow
Compile with java
Compile java file
javac -cp /usr/lib/tensorflow/libtensorflow-1.14.0.jar HelloTensorFlow.java
run java file:
java -cp /usr/lib/tensorflow/libtensorflow-1.14.0.jar:. -Djava.library.path=/usr/lib/tensorflow/ HelloTensorFlow
use MAVEN
First we should export LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/usr/lib/tensorflow
Then run maven build command:
mvn -q compile exec:java
I hope it helps you

How do I run a .class file created in a Mac on a windows?

I made a program in Java on my Macbook. It compiled and executed properly.
I took the .class file and tried to run it in an another machine with windows on it.
I wanted to examine the platform independent feature of Java.
It first gave me Java launcher error and then kept saying, main class not found.
I did run the program on my Mac using the terminal with the following commands javac file.java
and executed it with java classname
Took the class file and tried to run in a windows machine using the command line with the command java classname.
Things did not run then
Has nothing to do with the OS, if java is installed on the windows machine, the class files should run. First make sure you have the JVM installed, if that's not it, it is because your are not running your main class.
Run main from cmd with this command.
java -cp "ClassPath" FileName

issues Running GPUGalaxySim.java using aparapi jar in Oracle Java Development Kit on Windows

I've written a program that does some calculations to display a galaxy.I want to run it within jdk command prompt but i get this error.Compiling the program with aparapi works fine.When i try to run it,i get this:
Btw after i compile it I get many files which are these:
As u can see,the api library is in a different folder.
The commands I write are those two:
1)javac -g -cp ..\dist_windows_x86_64\aparapi.jar;. GPUGalaxySim.java
2)java -cp ..\dist_windows_x86_64\aparapi.jar;. -Djava.library.path=..\dist_windows_x86_64 GPUGalaxySim
Of course the commands are written after i go to the folder that contains the files u can see in the picture,called dist_x86_64.
Please help

Unable to run threaded java jar file on Mac OS X 10.6.8 with Java 1.7.0.45 using pacifist

I have installed Java 1.7.0_45 on Mac OS X 10.6.8 using Pacifist [http://www.charlessoft.com/] however I am unable to run a jar file which I have downloaded. The jar file is a threaded application.
The error message I am getting is:
java -jar context.jar
2013-10-31 14:14:41.898 java[330:a07] *** NSInvocation: warning: object 0x109356390 of class 'ThreadUtilities' does not implement methodSignatureForSelector: -- trouble ahead
2013-10-31 14:14:41.900 java[330:a07] *** NSInvocation: warning: object 0x109356390 of class 'ThreadUtilities' does not implement doesNotRecognizeSelector: -- abort
Trace/BPT trap
Is there anyway I can run the jar. I have set the JAVA_HOME path properly and java -version is showing 1.7.0_45 as the version.
The same application works properly on Windows Java 1.7.0_45 and also on Linux Java 1.7.
The web search for the solution and the given keywords return very few results and none of them have any specific solution in it. I am new to mac so I am not fully able to understand the issue.
Alternatively, is there anyway I can run Java from folder in Mac like I can do in windows and Linux by just extracting the Java contents and changing the JAVA_HOME. If that is possible then I should be able to run my JAR.
I had kind of same problem while installing an application through jar file, my Java was not detected by the jar application installer,
Over here I see that one of the method is not accessible, could be a same problem. But I am not very sure of it.
make sure you have rt.jar in your JAVA_HOME/jre/lib/ folder
In case you don't have then you are required to have it through the process of creation of symbolic link.
In the command below replace your_java_version with proper version matching your requirement.
sudo mkdir -p /System/Library/Frameworks/JavaVM.framework/Versions/<your_java_version>/Home/jre/lib
Go into the directory:
cd /System/Library/Frameworks/JavaVM.framework/Versions/<your_java_version>/Home/jre/lib/
Create symbolic link :
sudo ln -s ../../../Classes/classes.jar rt.jar
Hope this solves your problem.
I get the exact same problem with MacOS 10.6.8 and JDK 7. In order to run the jar I had to use the System JRE which is 1.6.x (In my case I wanted to install Squirrel
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -jar >squirrel-sql-3.6-MACOSX-install.jar

Cannot execute Java app on Vista Business - "Cannot find the main class... Program will exit"

I have written a Java GUI app (using Netbeans 6.7) requiring Java 1.6. I successfully run it on my XP PC and also my Mac OSX (10.5.7).
My client is running Vista Business, and cannot run the application by double clicking the jar file. He can execute it from the command line: "javaw -jar ..." The error received is: "Cannot find the main class... Program will exit".
I've asked the client to do the following:
install the latest JRE
run JarFix
I've verified that:
JRE is installed in correct location
jar file association is correct
application works (as I have tested it on XP and Mac OSX, and the client can run it from the command line)
Any ideas on what else I can investigate? Note, Netbeans created the main jar file, and also a lib directory with a couple of other Jarfiles. I've unzipped the jarfile and examined the manifest file (which looks good). The correct main class is also within the app's jarfile.
Does the client need to be careful as to where the application is executed from in Vista?
Thanks very much.
Prembo
Does exactly the same JAR file work on other operating systems?
Is the manifest file (META-INF/MANIFEST.MF) in the JAR file correct? One catch to watch out for is that the manifest file MUST end with an empty line; if it doesn't, the last line in the manifest file will be ignored. So, for example, if the last line in your manifest file is something like this:
Main-Class: com.mypackage.MyProgram
and it is not followed by an empty line, then Java will ignore the line and it will not be able to find the main class of the program.
See Sun's Java Tutorial about deploying Java programs in JAR files for exact details about how to package your application in a JAR; it also contains the warning about the manifest file needing to end with an empty line.
Also, double-check if the right version of Java is used. Are you using the exact same version of Java as on Windows XP? Try:
java -version
to see which Java version is being used.
I'm running Vista Enterprise and have very little differences between it and other Windows versions (with regards to Java).
Here are some random ideas that may or may not work:
Have you tried: right clicking on the Jar -> Open with -> Java(TM) Platform SE Binary
Could it be permissions related? (probably not since it runs via the command line)
Have you tried it with UAC off? (UAC sandboxes java apps, and they can't write to certain locations like Program Files)
Did you make sure they have the same files as you in JAVA_HOME/lib/ext/
you could try setting environment variables:
JAVA_HOME=<your_java_home>
CLASSPATH=.
PATH=<your_java_home>\bin
Sometimes JDK needs to be installed separately,along with the net beans IDE. If you have jdk installed then you can try checking for classpath,path in the environmental variables.

Categories