LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
Search this Thread
Old 09-07-2004, 09:56 PM   #1
kath
LQ Newbie
 
Registered: Aug 2003
Location: Canberra, Australia
Distribution: Red Hat 8.0
Posts: 2

Rep: Reputation: 0
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.
 
Old 09-07-2004, 10:29 PM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
Make sure you're setting CLASSPATH, not CLASS_PATH, and make sure "." is in it:

export CLASSPATH=.:$CLASSPATH
java Hello
 
Old 09-07-2004, 11:22 PM   #3
kath
LQ Newbie
 
Registered: Aug 2003
Location: Canberra, Australia
Distribution: Red Hat 8.0
Posts: 2

Original Poster
Rep: Reputation: 0
DOH!

Thanks... it works now.
 
Old 09-18-2004, 11:45 AM   #4
sywlyn
LQ Newbie
 
Registered: Sep 2004
Posts: 4

Rep: Reputation: 0
Unhappy

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.
 
Old 09-18-2004, 11:50 AM   #5
mirradric
Member
 
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188

Rep: Reputation: 31
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
 
Old 09-18-2004, 11:57 AM   #6
sywlyn
LQ Newbie
 
Registered: Sep 2004
Posts: 4

Rep: Reputation: 0
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?
 
Old 09-18-2004, 12:16 PM   #7
sywlyn
LQ Newbie
 
Registered: Sep 2004
Posts: 4

Rep: Reputation: 0
anyone, plz?
 
Old 09-18-2004, 12:18 PM   #8
mirradric
Member
 
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188

Rep: Reputation: 31
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.
 
Old 09-18-2004, 12:23 PM   #9
mirradric
Member
 
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188

Rep: Reputation: 31
oh...
I forgot that you have to
Code:
export PATH
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".
 
Old 09-18-2004, 12:30 PM   #10
sywlyn
LQ Newbie
 
Registered: Sep 2004
Posts: 4

Rep: Reputation: 0
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)
 
Old 09-18-2004, 12:33 PM   #11
mirradric
Member
 
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188

Rep: Reputation: 31
look somewhere towards the beginning of this thread....
sorry my concentration is slipping
 
Old 09-19-2004, 11:11 PM   #12
mirradric
Member
 
Registered: May 2004
Location: Singapore
Distribution: Debian woody and debian sarge
Posts: 188

Rep: Reputation: 31
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
 
Old 05-11-2006, 04:37 AM   #13
pradeepmenon777
Member
 
Registered: Jan 2004
Location: India
Distribution: Ubuntu 8.04
Posts: 122

Rep: Reputation: 16
Quote:
PATH=/path/to/sdk/bin:$PATH
export PATH
I tried this now . Thanks for the help given...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window serve paragvd Programming 4 10-05-2004 03:35 AM
Java error "Exception in thread "main" java.lang.StackOverflowError" nro Programming 1 09-04-2004 03:47 AM
Exception in thread "main" java.lang.NoClassDefFoundError: Lobais Linux - Software 19 06-23-2004 08:42 AM
Exception in thread "main" java.lang.NoClassDefFoundError: melinda_sayang Programming 2 04-27-2004 11:49 AM
Exception "NoClassDefFoundError" from java degraffenried13 Linux - Software 8 09-11-2003 11:45 AM


All times are GMT -5. The time now is 05:44 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration