My .jar file needs and uses some files in the same directory it’s in (everything, including the jar was unzipped into said directory). It runs perfectly when I do java -jar file.jar in the command line, but there’s trouble when I double-click the file when running from the file system manager.
I’ve tried a custom command under properties ie java -jar, but the problem is that the .jar file doesn’t seem to be able to use any of the files in the same directory. When running, the jar can’t find any of the files that it needs.
Does anyone know how to solve this problem? Thanks.
If you run it from the commandline you’re in the same folder as the jar file.
This means when you run the jar it will look in your current directory.
But when you run it from a file-manager your current directory is your home directory.
So the program will look for the files in your home directory.
You can still run it by using a command like this:
cd /<PATH>/<TO>/<JAR-file>/ && java -jar ./<JAR-file>.jar
Edward Iii wrote:
> This means when you run the jar it will look in your current directory.
> But when you run it from a file-manager your current directory is your
> home directory.
> So the program will look for the files in your home directory.
i think that problem is solved by setting the “java path”…a bit of
magic i don’t remember how to accomplish…but, i guess either java
docs or google knows…
This will only work if the files are classes or packages.
Because the option -classpath only tells the jvm(Java Virtual Machine) to look in that directory for classes or packages.
Here’s a bit from wikipedia: