• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Problem when executing the LWJGL native library under Java via shell script

 
Greenhorn
Posts: 4
Netbeans IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Thanks
Riz
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Isn't it something wrong with the quotes here

?
 
riz javaid
Greenhorn
Posts: 4
Netbeans IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Valery Lezhebokov wrote:Isn't it something wrong with the quotes here

?



Sorry, that was incorrectly copied from my part, I apologise. It should be:



When I run the entire shell script with the correct quote and echo the command I am trying to execute, it all looks fine, but I get UnsatisfiedLinkError.

I am in the correct directory, lwjgl/native/linux folder structure does exist in this directory and the so files and these folders are all executable, have correct permissions.

The reason for the shell script is because I want to launch an application without the user typing this long Java command in when the application is installed.
 
Sheriff
Posts: 22684
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try specifying the absolute path to the lwjgl folder.
 
riz javaid
Greenhorn
Posts: 4
Netbeans IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Try specifying the absolute path to the lwjgl folder.



I have tried with absolute path and get the same error.

1) I am running from bash terminal under the /home/riz/MyGame directory (where all JARs are contained and native libs)
2) I run the sh MyGame.sh from the bash terminal.

Could it be that when the shell executes the java command, when the new VM is running, it is not running in the current directory (/home/riz/MyGame)?

 
Rob Spoor
Sheriff
Posts: 22684
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
riz javaid
Greenhorn
Posts: 4
Netbeans IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.



I have solved the problem:

The line:

_VM_PROPERTIES='-Djava.library.path="lwjgl/native/linux"'



should be:

_VM_PROPERTIES=-Djava.library.path="lwjgl/native/linux"



(without the single quotes) and this works fine and starts up all good via the shell script AND if I try on the bash terminal command line.

Thanks for all your help and suggestions.

Riz
 
Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic