LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   java exception: java.lang.NoClassDefFoundError (https://www.linuxquestions.org/questions/programming-9/java-exception-java-lang-noclassdeffounderror-227969/)

kath 09-07-2004 09:56 PM

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.

CroMagnon 09-07-2004 10:29 PM

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

export CLASSPATH=.:$CLASSPATH
java Hello

kath 09-07-2004 11:22 PM

DOH!

Thanks... it works now.

sywlyn 09-18-2004 11:45 AM

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.

mirradric 09-18-2004 11:50 AM

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


sywlyn 09-18-2004 11:57 AM

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?

sywlyn 09-18-2004 12:16 PM

anyone, plz?

mirradric 09-18-2004 12:18 PM

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.

mirradric 09-18-2004 12:23 PM

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".

sywlyn 09-18-2004 12:30 PM

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)

mirradric 09-18-2004 12:33 PM

look somewhere towards the beginning of this thread....
sorry my concentration is slipping

mirradric 09-19-2004 11:11 PM

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


pradeepmenon777 05-11-2006 04:37 AM

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 10:20 PM.