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.
Hm I’ve looked more into the problem but still haven’t got it fixed; should I be adding file names to a classpath in the custom command? So that running the jar would retrieve the necessary files.
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:
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.
Is this a possible file association issue?
Which file manager are you referring to? For example, here’s how you would configure Konqeror