Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
09-07-2004, 09:56 PM
|
#1
|
LQ Newbie
Registered: Aug 2003
Location: Canberra, Australia
Distribution: Red Hat 8.0
Posts: 2
Rep:
|
java exception: java.lang.NoClassDefFoundError
Hi,
I've just installed j2sdk, using the self extracting binary on linux (debian). The install process seemed to go fine, and everything appears to be there.
I've got a REALLY basic hello world program:
public class Hello
{
public static void main(String[] args)
{
System.out.println("Hello");
}
}
saved as Hello.java
Compile it:
$HOME/java_code> javac Hello.java
no problems, but when I try to run it:
$HOME/java_code> java Hello
I get:
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
I've tried setting the PATH, JAVA_HOME, and CLASS_PATH variables, but it doesn't seem to make any difference.
I realise this question has been asked before, but most of the responses seemed to be: try setting your CLASS_PATH.... which hasn't helped.
Can someone help me please?
Kath.
|
|
|
09-07-2004, 10:29 PM
|
#2
|
Member
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900
Rep:
|
Make sure you're setting CLASSPATH, not CLASS_PATH, and make sure "." is in it:
export CLASSPATH=.:$CLASSPATH
java Hello
|
|
|
09-07-2004, 11:22 PM
|
#3
|
LQ Newbie
Registered: Aug 2003
Location: Canberra, Australia
Distribution: Red Hat 8.0
Posts: 2
Original Poster
Rep:
|
DOH!
Thanks... it works now.
|
|
|
09-18-2004, 11:45 AM
|
#4
|
LQ Newbie
Registered: Sep 2004
Posts: 4
Rep:
|
HI, I really need some help. I just installed LInux SuSE 9.1 and I cant get javac to work, it tells me the following
javac: command not found.
Exacly how do I set the paths I see you people talking about? Please. Im really new to java and Have no idea whats going on with the JSDK.
I downloaded the 1.4 sdk from sun and installed it without problems. I just dont know what to enter into the command to get my code to compile.
Plz help, thanks.
|
|
|
09-18-2004, 11:50 AM
|
#5
|
Member
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188
Rep:
|
If i'm not mistaken, the installation of sun's jdk do not put the symlinks of the java executables (java, javac etc) into /usr/local/bin ( that's where you want it right?)
You'll have to create them yourself or add the bin directory of the sdk to your path.
BTW, to see your PATH and CLASSPATH env variables just
Code:
echo $PATH
echo $CLASSPATH
|
|
|
09-18-2004, 11:57 AM
|
#6
|
LQ Newbie
Registered: Sep 2004
Posts: 4
Rep:
|
lol, thanks mirradric.
Basically what i did is downloaded the sdk from sun, version 1.4
installed it and thats about it
Doing the echo i got the following results:
sywlyn@sywlyn:~/Documents/projects marked/PersonalOrganizer> echo $PATH
/home/sywlyn/bin:/home/sywlyn/bin/:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/java/jre/bin
when I tried to echo classpath nothing happend at all. Should I change anything?
Add the them? should I go into the bin directory where javas sdk was installed and copy the contents "which includes javac" into /usr/local/bin ?
I know when I installed my windows sdk I had to change variables, but I dont know how or where to change them in linux?
|
|
|
09-18-2004, 12:16 PM
|
#7
|
LQ Newbie
Registered: Sep 2004
Posts: 4
Rep:
|
anyone, plz?
|
|
|
09-18-2004, 12:18 PM
|
#8
|
Member
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188
Rep:
|
to add something to your path, edit /etc/profile or equivalent and add something like
Code:
PATH=/path/to/sdk/bin:$PATH
replacing the text in bold with your actual path
or you can create links in /usr/local/bin to the individual program/command that you want users to run.
If you want the jre plugin in your web browser I think the instructions are there as well.
Last edited by mirradric; 09-18-2004 at 12:19 PM.
|
|
|
09-18-2004, 12:23 PM
|
#9
|
Member
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188
Rep:
|
oh...
I forgot that you have to
and you have to logout and in again for it to work, or you can type this in an xterm and it'll work for that particular xterm and it's "spawns".
|
|
|
09-18-2004, 12:30 PM
|
#10
|
LQ Newbie
Registered: Sep 2004
Posts: 4
Rep:
|
thanks alot mirradric, it worked!  thanks. I see unlike windows when it comiles it doesnt automaticly launch the application.
I do however get NoClasDefFound error now when I type in: java (classname)
|
|
|
09-18-2004, 12:33 PM
|
#11
|
Member
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188
Rep:
|
look somewhere towards the beginning of this thread....
sorry my concentration is slipping
|
|
|
09-19-2004, 11:11 PM
|
#12
|
Member
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188
Rep:
|
just in case people read this the wrong way; it was way past my bedtime.
Quote:
Originally posted by mirradric
look somewhere towards the beginning of this thread....
sorry my concentration is slipping
|
|
|
|
05-11-2006, 04:37 AM
|
#13
|
Member
Registered: Jan 2004
Location: India
Distribution: Android 9.0.6
Posts: 123
Rep:
|
Quote:
PATH=/path/to/sdk/bin:$PATH
export PATH
|
I tried this now . Thanks for the help given...
|
|
|
All times are GMT -5. The time now is 12:53 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|