Reputation: 1727
I am trying to run a jar file on linux of swing project using JavaFX . I have installed JRE7 on linux .
My project jar is using two jars: jfxrt.jar and lucene.jar . I have copied the jars to /home/projectdir/lib/ and also set the classpath by following command
export CLASS PATH=/home/projectdir/lib/jarfilename.jar
but I am still getting an error while running my project jar with the help of following command:
java -jar projectjar.jar
Upvotes: 2
Views: 221
Reputation: 2739
you have a typo in enviroment variable: it should be CLASSPATH (without space in the middle). Also you will need to put both jars:
export CLASSPATH=/home/projectdir/lib/jfxrt.jar:/home/projectdir/lib/lucene.jar:projectjar.jar
or better use relative paths:
export CLASSPATH=lib/jfxrt.jar:lib/lucene.jar:projectjar.jar
But you must use main class name, not -jar, as pointed out in another answer.
Upvotes: 4
Reputation: 38132
AFAIK, the classpath settings are ignored when using the -jar option. Use the -cp option and specify the main class on the command line.
From the documentation:
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html#jar
-jar
Execute a program encapsulated in a JAR file. The first argument is the name of a JAR file instead of a startup class name. In order for this option to work, the manifest of the JAR file must contain a line of the form Main-Class: classname. Here, classname identifies the class having the public static void main(String[] args) method that serves as your application's starting point. See the Jar tool reference page and the Jar trail of the Java Tutorial for information about working with Jar files and Jar-file manifests. When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.
Upvotes: 1