This issue is related to running a Java program (jar) dependent on thirdparty jar library even after setting classpath and trying so many other methods by reading articles in Internet.
I want to use a thirdparty Pack1.jar (it is not a part of jvm) as dependency of my programme.
I do not know where the Pack1.jar file could be in the deployment machine and I want the deployer to specify the path for the thirdparty libraries
I have tried the following alternatives in vain
-
Setting the java.class.path programatically
String class_path = args[0]; System.setProperty("java.class.path",class_path);Here I am assuming that deployer would supply the classpath as first argument while running the program
-
Setting the CLASSPATH env_var to locate the thirdparty directory
-
While running, using the classpath option
java -classpath /path/to/Pack1.jar -jar Pack2.jarI think this would not work because documentation says that classpath is ignored when program is run with “java -jar”
-
Setting the java.ext.dirs programatically.
- Setting the java.library.path programatically.
I do not want to specify the Class-Path in manifest because that takes only relative path and I do not know where the thirdparty library would be kept in deployment machine
But I am unable to get the jar running.
How can I fix this problem any help please.
Go for option 3. Put both jars on the classpath like this:
Note, that this is for Linux. on Windows, you would separate classpath elements with semicolons:
http://en.wikipedia.org/wiki/Classpath_%28Java%29