Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO : Setting up my java CLASSPATH ??????
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
luche
n00b
n00b


Joined: 19 Apr 2002
Posts: 21
Location: Quebec

PostPosted: Fri Jun 14, 2002 8:26 pm    Post subject: HOWTO : Setting up my java CLASSPATH ?????? Reply with quote

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 :D

Luc.
Back to top
View user's profile Send private message
Coogee
Apprentice
Apprentice


Joined: 23 Apr 2002
Posts: 184
Location: E.U.

PostPosted: Fri Jun 14, 2002 9:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
proxy
Apprentice
Apprentice


Joined: 20 Apr 2002
Posts: 260
Location: Chantilly, VA

PostPosted: Fri Jun 14, 2002 9:45 pm    Post subject: Reply with quote

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 :P

just do this

Code:
CLASSPATH=$CLASSPATH:.


works for me ;)
Back to top
View user's profile Send private message
rizzo
Retired Dev
Retired Dev


Joined: 30 Apr 2002
Posts: 1067
Location: Manitowoc, WI, USA

PostPosted: Fri Jun 14, 2002 9:48 pm    Post subject: Re: HOWTO : Setting up my java CLASSPATH ?????? Reply with quote

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
View user's profile Send private message
jtanner
Tux's lil' helper
Tux's lil' helper


Joined: 23 May 2002
Posts: 121
Location: Atlanta, GA

PostPosted: Sat Jun 15, 2002 2:02 am    Post subject: Reply with quote

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
View user's profile Send private message
neuron
Advocate
Advocate


Joined: 28 May 2002
Posts: 2371

PostPosted: Sat Jun 15, 2002 2:38 am    Post subject: Reply with quote

emerge ant

;)
Back to top
View user's profile Send private message
luche
n00b
n00b


Joined: 19 Apr 2002
Posts: 21
Location: Quebec

PostPosted: Mon Jun 17, 2002 2:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
rieger
Tux's lil' helper
Tux's lil' helper


Joined: 14 Jun 2002
Posts: 136
Location: The Netherlands

PostPosted: Thu Sep 19, 2002 7:36 pm    Post subject: Reply with quote

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.

:x
_________________
haree
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum