I know there is this article on JAR files on Linux but the solution involves some Linux specific commands I don't know, and ultimately I'd like to understand if I can access my JAR (and JARs it depends on) without having to write a script.
I am on Windows 7 and my main Java class is org.sync.MainEntry
located in my main JAR called synchronizer.jar
. I placed the absolute path of all the other JARs it depends on into my CLASSPATH
variable in Computer -> Advanced Settings -> Environment Variables. I even tried moving those JARs into the same folder as my main JAR.
But, when I execute (in command-prompt, navigated to my main JAR, with or without other JARs) the following call:
java org.sync.MainEntry
I get an "Unable to access jarfile org.sync.MainEntry" error. So I move ALL the JARs into the same place and have to do
java -cp my_other_jar.jar;my_other_other_jar.jar;synchronizer.jar org.sync.MainEntry
and that finally works. Or I can replace all the jars with just *. But, I either need to move all the JARs to the same place or put in full paths and I feel there's gotta be a way to do with without creating a shell script or writing out the full JAR paths each time.
Based on the article mentioned above, I am happy to accept that CLASSPATH
doesn't see jars, just the classes inside, but a JAR is an archive, maybe I can extract them somehow and point the CLASSPATH
to there?
Thanks in advance for your help!