LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Paths in Java application... (https://www.linuxquestions.org/questions/linux-general-1/paths-in-java-application-802065/)

Alexvader 04-14-2010 07:18 PM

Paths in Java application...
 
Hi...

So, I have this application called Impact, it is an explicit time integration Finite Elements code written in Java...

http://impact.sourceforge.net/

I untar the pack, and launch the application calling a script, from within the untarred folder,

Code:

alex@iskandhar:~/stuff/Impact$ ls
COPYING                  ImpactClusterServerKill.bat          ImpactGUI_JOGL_OGL_solaris_sparcv9.sh  ImpactGUI_OGL_windows_amd64.bat  Pro.conf      featured.ico
Constraints.properties  ImpactClusterServerKill.sh          ImpactGUI_JOGL_OGL_windows_amd64.bat  ImpactGUI_OGL_windows_i586.bat  README        impact.png
Graph.conf              ImpactClusterTask.bat                ImpactGUI_JOGL_OGL_windows_i586.bat    ImpactOpt.bat                    bin/          interfaces/
Impact.bat              ImpactClusterTask.sh                ImpactGUI_OGL_linux_amd64.sh*          ImpactOpt.sh                    bin_cluster/  jalopy.xml
Impact.ico              ImpactGUI_JOGL_OGL_linux_amd64.sh    ImpactGUI_OGL_linux_i586.sh            License.txt                      build.xml    lib/
Impact.sh*              ImpactGUI_JOGL_OGL_linux_i586.sh    ImpactGUI_OGL_macosx.sh                Loads.properties                cluster.png  lib_cluster/
ImpactClusterClient.bat  ImpactGUI_JOGL_OGL_macosx.sh        ImpactGUI_OGL_solaris_amd64.sh        Material.properties              debug.bat    lib_j3d/
ImpactClusterClient.sh  ImpactGUI_JOGL_OGL_solaris_amd64.sh  ImpactGUI_OGL_solaris_i386.sh          Opt.conf                        debug.sh      make.bat
ImpactClusterServer.bat  ImpactGUI_JOGL_OGL_solaris_i386.sh  ImpactGUI_OGL_solaris_sparc.sh        Post.conf                        doc/          src/
ImpactClusterServer.sh  ImpactGUI_JOGL_OGL_solaris_sparc.sh  ImpactGUI_OGL_solaris_sparcv9.sh      Pre.conf                        examples/
alex@iskandhar:~/stuff/Impact$./ImpactGUI_OGL_linux_amd64.sh

This launches a gui which allows me to setup a case, which needs some setup file, tipically some *.in and a mesh file, tipically some *.msh.

Other mode of executuion consists of calling the setup file as argument to Impact.sh script ( CLI execution mode, for g33k5 :D )


My problem is : I have packed the whole stuff into a Slackware .tgz, that places it in /usr/local/Impact, and placed a calling script in /usr/local/bin ,

Code:

alex@iskandhar:~/stuff/Impact/build# echo '/usr/local/Impact/ImpactGUI_OGL_linux_amd64.sh' > /usr/local/bin/Impact&&chmod +x /usr/local/bin/Impact
Why the heck doesn't it find the java libraries even after i having created the package with makepkg -l y -c n /path/to/package.tgz...?

Code:

Meskimen's Law:
        There's never time to do it right, but there's always time to
do it over.

alex@iskandhar:~$ impact
bash: impact: command not found
alex@iskandhar:~$ Impact
Exception in thread "main" java.lang.NoClassDefFoundError: gui/ImpactGUI
Caused by: java.lang.ClassNotFoundException: gui.ImpactGUI
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: gui.ImpactGUI.  Program will exit.
alex@iskandhar:~$


I decided to hack the ImpactGUI_OGL_linux_amd64.sh script from

Code:

alex@iskandhar:~$ cat /usr/local/Impact/ImpactGUI_OGL_linux_amd64.sh
#!/bin/sh
export LD_LIBRARY_PATH=lib_j3d/linux_amd64
java -Xmx1000m -Xss1m -cp .:bin:doc:lib/jogl.jar:lib/gluegen-rt.jar:lib/patbinfree153.jar:lib_j3d/j3dcore.jar:lib_j3d/j3dutils.jar:lib_j3d/vecmath.jar -Djava.library.path="lib_j3d/linux_amd64" gui.ImpactGUI

to

Code:

alex@iskandhar:~$ cat /usr/local/Impact/ImpactGUI_OGL_linux_amd64.sh
#!/bin/sh
export LD_LIBRARY_PATH=/usr/local/Impactlib_j3d/linux_amd64
java -Xmx1000m -Xss1m -cp .:bin:doc:lib/jogl.jar:lib/gluegen-rt.jar:lib/patbinfree153.jar:lib_j3d/j3dcore.jar:lib_j3d/j3dutils.jar:lib_j3d/vecmath.jar -Djava.library.path="lib_j3d/linux_amd64" gui.ImpactGUI


no avail,


Code:

alex@iskandhar:~$ Impact
Exception in thread "main" java.lang.NoClassDefFoundError: gui/ImpactGUI
Caused by: java.lang.ClassNotFoundException: gui.ImpactGUI
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: gui.ImpactGUI.  Program will exit


even after adding /usr/local/Impact/bin to PATH... won't go...

Can someone please tell me what is wrong here...?

I can run this thing from within its directory... but I do not like messing within the directories of my applications, this is why I sent this to /usr/local, and placed a calling script in /usr/local/bin...

Why can't this go...?

BRGDS

Alex

kbp 04-14-2010 08:32 PM

What does your calling script look like ?

timufea 04-15-2010 02:36 AM

The NoClassDefFoundError exception is thrown because the class files needed by the application could not be found. These class files are stored in .jar files listed in the '-cp' ("classpath") option on the java command line.

You could modify the '-cp' option in your script to use absolute pathnames for the .jar files, but it's easier to simply have the script change directory:

Code:

#!/bin/sh
cd /usr/local/Impact
export LD_LIBRARY_PATH=lib_j3d/linux_amd64
java -Xmx1000m -Xss1m -cp .:bin:doc:lib/jogl.jar:lib/gluegen-rt.jar:lib/patbinfree153.jar:lib_j3d/j3dcore.jar:lib_j3d/j3dutils.jar:lib_j3d/vecmath.jar -Djava.library.path="lib_j3d/linux_amd64" gui.ImpactGUI

If you prefer to use absolute pathnames, you should note that your modified LD_LIBRARY_PATH is missing a '/' (i.e. it should be /usr/local/Impact/lib_j3d/linux_amd64).

Alexvader 04-15-2010 02:32 PM

Quote:

Originally Posted by kbp (Post 3935867)
What does your calling script look like ?

Hi Kbp

this is it... :

Code:

alex@iskandhar:~$ cat /usr/local/bin/Impact
/usr/local/Impact/ImpactGUI_OGL_linux_amd64.sh
alex@iskandhar:~$ cat /usr/local/Impact/ImpactGUI_OGL_linux_amd64.sh
#!/bin/sh
export LD_LIBRARY_PATH=/usr/local/Impact/lib_j3d/linux_amd64
java -Xmx1000m -Xss1m -cp .:bin:doc:lib/jogl.jar:lib/gluegen-rt.jar:lib/patbinfree153.jar:lib_j3d/j3dcore.jar:lib_j3d/j3dutils.jar:lib_j3d/vecmath.jar -Djava.library.path="lib_j3d/linux_amd64" gui.ImpactGUI
alex@iskandhar:~$

BRGDS

Alex

Alexvader 04-15-2010 02:37 PM

Hi Timufea

Hacked the script to cd into /usr/local/Impact...

seems allright for now... :)

Thkz

BRGDS


Alex


All times are GMT -5. The time now is 12:23 PM.