View previous topic :: View next topic |
Author |
Message |
luche n00b
Joined: 19 Apr 2002 Posts: 21 Location: Quebec
|
Posted: Fri Jun 14, 2002 8:26 pm Post subject: HOWTO : Setting up my java CLASSPATH ?????? |
|
|
Hi to all !!!
I've searched the forum, read the gentoo docs on java and I wasn't able to find a suitable answer.
So here I am posting to get it done !!!
I've installed sun-jdk-1.4.0 and java-config-0.2.4 without any problem. Ran java-config with the set-system-vm (as root) and then set-user-vm (as a normal user) just to be sure.
So far so good, I can compile a simple Hello World program... but can't run it...
Now, when trying to run java-config --list-available-packages I get these two lines :
Code: |
ls: /usr/share/*/classpath.env: No such file or directory
ls: /usr/share/*/package.env: No such file or directory
|
Does anyone out there know how to make this work ???
Because even though my simple program compiles, when executed I get the following error :
Code: |
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
|
And that I know is because my CLASS_PATH var isn't set right.
Thanks in advance for any answer !!!
Have a nice day
Luc. |
|
Back to top |
|
|
Coogee Apprentice
Joined: 23 Apr 2002 Posts: 184 Location: E.U.
|
Posted: Fri Jun 14, 2002 9:14 pm Post subject: |
|
|
I copied the file 20sun-jdk-1.4.0 from /etc/env.d/java/ to /etc/env.d/
After reboot all necessary paths were available. |
|
Back to top |
|
|
proxy Apprentice
Joined: 20 Apr 2002 Posts: 260 Location: Chantilly, VA
|
Posted: Fri Jun 14, 2002 9:45 pm Post subject: |
|
|
i find that that last error
Code: | Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld |
is usually caused by "." (current directory) not being in the classpath. It seems that java-config does not do this for you (as it should). At least I can't get it to do it for me
just do this
Code: | CLASSPATH=$CLASSPATH:. |
works for me |
|
Back to top |
|
|
rizzo Retired Dev
Joined: 30 Apr 2002 Posts: 1067 Location: Manitowoc, WI, USA
|
Posted: Fri Jun 14, 2002 9:48 pm Post subject: Re: HOWTO : Setting up my java CLASSPATH ?????? |
|
|
luche wrote: |
And that I know is because my CLASS_PATH var isn't set right.
. |
The environment variable is CLASSPATH, not CLASS_PATH. If you have been setting CLASS_PATH, that also might be a problem. Or it may be just a typo in this post. Just an FYI. |
|
Back to top |
|
|
jtanner Tux's lil' helper
Joined: 23 May 2002 Posts: 121 Location: Atlanta, GA
|
Posted: Sat Jun 15, 2002 2:02 am Post subject: |
|
|
Also, don't forget to account for packages in the classpath. For example, if you have:
Code: |
package HelloWorldPackage;
public class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello, world");
}
}
|
then HelloWorld.class will need to be in a subdirectory named HelloWorldPackage, and the directory containing HelloWorldPackage will need to be in your classpath.
Hope this helps.
Jim |
|
Back to top |
|
|
neuron Advocate
Joined: 28 May 2002 Posts: 2371
|
Posted: Sat Jun 15, 2002 2:38 am Post subject: |
|
|
emerge ant
|
|
Back to top |
|
|
luche n00b
Joined: 19 Apr 2002 Posts: 21 Location: Quebec
|
Posted: Mon Jun 17, 2002 2:54 pm Post subject: |
|
|
Oh well found the error myself... Added the current path from where i'm working in the CLASSPATH env variable.
It's now working !!!
Thanks to everyone who posted an answer
Have a nice day ! |
|
Back to top |
|
|
rieger Tux's lil' helper
Joined: 14 Jun 2002 Posts: 136 Location: The Netherlands
|
Posted: Thu Sep 19, 2002 7:36 pm Post subject: |
|
|
proxy wrote: |
Code: | CLASSPATH=$CLASSPATH:. |
works for me |
I know that this is the way to set it.
When I do java -cp . HelloWorld, it works.
But I can set every env. variable in this way, except...
CLASSPATH.
It doesn't seem to work.
_________________ haree |
|
Back to top |
|
|
|