I am running a Java application on the command line bash shell. I have a few JAR files in the directory and a few native libraries. When I run the application using the command line, all works fine. This is the command I use (assuming I change directory to where application is installed):
This works fine and the application starts up as expected. LWJGL native library is loaded in and works fine as expected.
The problem occurs when I try to run this command via the shell using a shell script. Here is my script:
The shell script is in the same directory as the JAR files (the same directory where I ran the Java command above). When I execute the shell script ( sh MyGame.sh ), I get the UnsatisfiedLinkError message:
I don't understand what I am doing wrong. I am executing the exact same command via a shell script and it is not working. I have echoed the Java command I build in the shell script and it is identical to the one I type in. Any ideas, solutions, most welcome. Is there a special way to load libraries when using a shell?
I am running Linux Mint Debian 201012, Linux mint 2.6.32-5-amd64 #1 SMP Thu Nov 25 18:02:11 UTC 2010 x86_64 GNU/Linux. JDK is 1.6.0_22 64-bit. I have 64-bit .so files in the correct place too as the Java command works. Also, file permissions are correct.
Definitely. With shell scripts, both on Windows and Linux / Unix, you should never assume it knows which path it's running in, and also never assume that any variables like $PATH (%PATH% in Windows) are set.
Rob Spoor wrote:Definitely. With shell scripts, both on Windows and Linux / Unix, you should never assume it knows which path it's running in, and also never assume that any variables like $PATH (%PATH% in Windows) are set.