You are not logged in.
Pages: 1
Hi everybody,
I am sure this is not hard, but I have been looking for some time now and just couldn't figure out how to do it. Trying to run simple java applications (I am just learning...) I allways get this error
Exception in thread "main" java.lang.NoClassDefFoundError: /opt/java/jre/bin/
Caused by: java.lang.ClassNotFoundException: .opt.java.jre.bin.
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
So after doing some research I am pretty sure this is because my classpath is not set, but I can't figure out the correct directory. I assumed this would be
/opt/java/bin
So I added these lines to my .basrc
export PATH=/opt/java/bin:$PATH
export JAVA_HOME="/opt/java/"
export CLASSPATH=.:/opt/java/
I think java is installed just fine, cause I can run eclipse without problems..
But it doesn't work... so please help me :)
Last edited by daJense (2009-05-25 14:10:49)
Offline
If you install jre from repos, I think java is in the path.
Try run this to see java in your system path:
echo $PATH
Offline
Java should be able to find and load the classes in the standard library on its own, without you explicitly specifying their location. If you want to use any other libraries you have to either set the CLASSPATH variable or use the -cp argument when invoking the VM.
Your error looks somewhat strange, can you post the command you use when you try to start applications and maybe the code of something you try to start?
Offline
First, Thx for replying.. so here is what I get using echo
[jens@jense-mobile Kap02]$ echo $PATH
/opt/java/bin:/opt/java/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/share/eclipse:/opt/java/bin:/opt/java/jre/bin:/opt/kde/bin:/usr/share/netbeans/bin/:/usr/bin/perlbin/site:/usr/bin/perlbin/vendor:/usr/bin/perlbin/core:/opt/qt/bin:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc:/home/db2inst1/sqllib/db2tss/bin
[jens@jense-mobile Kap02]$
Now for studying I try to run simple java apps from commandline. Using the -cp option I got my programm to work (it's "HelloWorld"). So if I set up a directory
~/javaapps/
How would I set this path so I don't have to use the -cp option every time I invoke an app
?
Offline
Never mind, I solved it. So if anybody else stumbles over this:
Do not execute your java command using the .java extension. Meaning if you try to invoke the command
java HelloWorld.java
it will fail. If you just do
java JHelloWorld
it will work. I feel stupid, but thx for your help, it pointed me in the right direction..
Offline
for even more noobs that i....
i just install java JRE from aur, but my apps doest run, "java command not found" then i ran
export PATH=/opt/java/bin:$PATH
export JAVA_HOME="/opt/java/"
export CLASSPATH=.:/opt/java/
classpath in path?, /opt/java is the path of java, anyway they ran just fine now
Last edited by Draconiak (2009-07-09 18:46:09)
Offline
Pages: 1