Getting the NoClassDefFoundError in my Dapper Terminal

Heya. So for some reason even though I can compile files within an Eclipse Project, I'm still running into issues whenever I try and do it through the terminal.

trenog@trenog-desktop:~/workspace/helloworld$ javac Hello.java

trenog@trenog-desktop:~/workspace/helloworld$ java Hello

Exception in thread "main" java.lang.NoClassDefFoundError: Hello

This is despite the fact that I'll get the following:

trenog@trenog-desktop:~/workspace/helloworld$ javac -version

javac 1.5.0_11

...

trenog@trenog-desktop:~/workspace/helloworld$ java -version

java version "1.5.0_11"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)

Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)

Anyone got any ideas?

[805 byte] By [trenoga] at [2007-11-27 5:33:46]
# 1
You have a classpath problem. You need to tell java where to look for the .class files. Write java -classpath . Helloand it should work.
ktm5124a at 2007-7-12 15:01:19 > top of Java-index,Java Essentials,Java Programming...
# 2

HI trenog

When you work in command line you need to specify the classpath properly.

http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/classpath.html

In Many IDEs it take cares of your CLASSPATH.

But when you come to command line you need to specify your system variable CLASSPATH.

in windows peopel use to specify CLASSPATH as

SET CLASSPATH = %CLASSPATH%;.

Dot at the end specify the current path. whereever you run the java command the current path as been take into classpath.

My Recomendation is try to use Apache ANT http://ant.apache.org/ ;) its a nice tool to set all the setting and work with.

ANT - Java programmers best friend :)

Message was edited by:

rrhegde

Message was edited by:

rrhegde

rrhegdea at 2007-7-12 15:01:19 > top of Java-index,Java Essentials,Java Programming...
# 3

So lets say that the place where I've thus far kept my .java files is my /home/workspace/ directory, with each program in its own folder. And let's also say that my java edition could be found in /usr/lib/j2sdk1.5-sun/.

How should I add to my classpath such that all my java files can be run in the terminal, or what should I put to at least get my local folder of java files to run?

Also, as for Ant, I've currently got installed version 1.6.5-3ubuntu1, not that this fact gives me any insight in how to use it.

trenoga at 2007-7-12 15:01:19 > top of Java-index,Java Essentials,Java Programming...
# 4
Read this and go through the exercise: http://www.kevinboone.com/classpath.html ... it's worth the time 10 times over, and then some.Read your ant manual... it's actually pretty good... I think it's a seperate download still though.
corlettka at 2007-7-12 15:01:19 > top of Java-index,Java Essentials,Java Programming...