0

I HOPE that's not your classpath!!!! :lol:
It should poin to the tools.jar file in your jdk directory:

Something along the lines of this:
C\Program Files\Java\jdk1.5.0\lib\tools.jar

Take a look at this, this was one of my earlier posts.

OK - so this is now what I have:

PATH: (a bunch of other things, then); C:\j2sdk1.4.2_08\bin\

CLASSPATH: C\j2sdk1.4.2_08\lib\tools.jar

I tried again. No luck. Should I try rebooting?

And, yes, that really was my CLASSPATH! :confused:

0

Nah, don't worry about rebooting.

Try putting a : colon after the C, and see if that works. I noticed you were missing it, but don't know if it's just a typo on this forum, or your reall classpath.

0

Did it - no change..... Even double-checked that my "0" was a zero, not a capital o by mistake...

Edit:
Ah ha!! Found it! I tried setting my classpath with just a period after it -it worked!

Thanks for all your help!

0

Hmm. Why don't you look inside Program Files/Java and see if there is any jdk directory theirs. I'm thinking there is, but not sure. If there is, change the path to point to that, rather than what you have right now. Let me know what you find.

0

I tried setting my classpath with just a period after it -it worked! I'm in!! Wahoo!

Thanks for all your help!

0

Hi there...

I have same problem here....
I did all as posted....

my environmental variable :
PATH : c:\javacomp\bin
CLASSPATH .;%classpath%.;C:\apidir\lib\api-5.0.jar

I try to run it but it return :

Exception in thread "main" java.lang.NoClassDefFound gov/nih/nlm/kss/util/DatabaseException

is it possibly a firewall issue?

I am a beginner in Java so detail help would be great..... :sad:

0

Hi all...

I was having the same trouble with running my java code...
Server_crash advice was really helpful..

in my case i was finally able to run my code successfuly by moving my ".class" files to "\bin" folder.. the ".java" files can be stored anywhere though..

as for the Environment Variables :
i added following

classpath : " <java directory>\bin" ; "<java directory>\lib
JAVA_FONTS : c:\winnt\fonts (in my case)
JAVE_HOME : e:\jdk1.3 (in my case)
path : "<java directory>\bin"

Ud

0

Just try by setting the classpath in the command prompt
C:\>set classpath =%classpath%;.;
and then execute the class again.

0

Hey guys here are my Environmental Variable settings same problem as most of you compiles fine but same error at runtime

CLASSPATH C:\j2dk\lib\comm.jar;C:\j2dk\lib\tools.jar;
also tried %classpath%;C:\j2dk\lib\comm.jar;C:\j2dk\lib\tools.jar;

PATH C:\j2dk\bin

tried moving .class file to C:\j2dk\bin but still no joy at runtime

Thank you in advance

Brian

0

Try this (I have no idea why it works):

For Classpath: type a period, and only a period. Really - it works!

0

hi

i had this error i think twice. once the footpath wasnt set properly and the other time i compiled a class with no main.

so check for these two,

:) :mrgreen:

0

you should NEVER EVER put classes or jars from the JDK installation in your classpath.
It's not needed and can cause problems.

You SHOULD put the current directory ('.') in there or else pass it as a classpath to the java compiler and runtime always.

If you still get a NoClassDefFoundError you're missing something on your classpath, which will pretty much always be a library you need for some import or other.

0

you should NEVER EVER put classes or jars from the JDK installation in your classpath.
It's not needed and can cause problems.

You SHOULD put the current directory ('.') in there or else pass it as a classpath to the java compiler and runtime always.

If you still get a NoClassDefFoundError you're missing something on your classpath, which will pretty much always be a library you need for some import or other.

You should have said something earlier before I led these people on for 40 posts!!!

0

It also has some serious errors...
1) you don't need to restart your computer when you're running XP, NT, or Win2K.
2) you should set JAVA_HOME and refer to that in your path instead of the full installation directory. Many applications expect JAVA_HOME to be set and it also makes upgrading a lot easier :)
3) of course the actual directory to set depends on the exact JDK version you're using and where you install it.

But apart from that it's a nice checklist :)

0

Hi,
Just try to set the classpath in the path of the folder where u r trying to compile.
Just try by setting the classpath in the command prompt
C:\xyz\234>set classpath =%classpath%;.;
and then execute the class again there
C:\xyz\234>java brian

0

Assuming you are using J2SDK you the class files for lang etc., are in the tools.jar file. You therefore need to add this file to your CLASSPATH.
E.g.,

.;c:\j2sdk1.4.1_02\bin;c:\j2sdk1.4.1_02\lib;c:\j2sdk1.4.1_02\lib\tools.jar

Simply replace j2sdk1.4.1_02 with whichever SDK you are using. Search for the tools.jar file if you are unsure where to look.

0

I had this same problem and was able to resolve it by simply re-saving the .java file with a different name and recompiling.

0

Actuallly, when you find the folder containing the source file(.java), you should notice the .class file is not in that same folder. If it is, then we have problems!

Hi, I'm a brand new newbie following this thread with great interest. I can run the "HelloWorldApp" just fine at the DOS command line; but, I want to learn to use NetBeans IDE. When I plug HelloWorldApp.java into NetBeans it compiles successfully into the same folder; however, when I try to run I get the above error message, followed by the encouragement "BUILD SUCCESSFUL" (no "HelloWorld" output, however). I've tried futzing around with the classpath stuff till I'm blue in the face! It can't be this hard! Any ideas?
Thanks

0

Guys, I finally got "HelloWorldApp" to work from within NetBeans IDE. It appears my problem was that I had put both HelloWorldApp.java and HelloWorldApp.class (from an earlier DOS prompt compile) directly into the project path. Therefore, when I ran the code within NetBeans I got a new "build" with only the compiled code, and not the source; I was confused because my original source and class file were still together in their original place - so I didn't understand why Java couldn't find the source. Anyway, I obviously have a lot to learn! If anyone can suggest a way I can clear up my considerable confusion about how this all works, I would be eternally gratefull!

0

hi i am getting this error too but i dont use command line (and dont plan to) im using textPad, and i installed it after i installed the jdk, so even after reading these helpful post i still dont understand where my problem is. the .java file is in the same folder as the .class. im not that new to java, but i've just begun to work at home and am unfamilier with setting up the editor and such to make it work (at school it was already good to go:sad:)

0

Hey all,
i'm kinda having this same problem.. in fact i'm just trying to run in the DOS prompt. Codings written for Applets (appletviewer sach.html ) run perfectly in dos prompt, after i set the Classpath n all.

But, a simple java program, gives me this same error , when i try to run using >>java Sach
after successfully compiling using javac..
Exception in thread "main" java.lang.NoClassDefFoundError: Sach

i set my classpath to the following
path=C:\Program Files\Java\jdk1.5.0_05\bin
(btw, i guess this sounds correct ya? coz ,well the javac command works fine. It doesn't even give any compile errors).

i hope someone can help me out plz. it's really confusing..:confused:

Regards,
Sachitha

0

It looks like you have set the PATH but NOT the CLASSPATH.

For CLASSPATH - just put a period in as the variable. Really. It's weird, but it works.

If you're not sure how to do this, let me know.

Good luck!


PS You might want to try to install JCreator instead - it's free, and you don't have to do all this nonsense - I don't think.

0

i set the PATH and CLASSPATH using the following link which was posted in this page itself
(http://www.cs.ucsb.edu/~teliot/Path_and_Classpath.htm )
but that's for jdk 1.5.0_02, but i'm having jdk 1.5.0_05...
i gave for the CLASSPATH a . (a fullstop)
Now how do i run programs in the Command prompt???
i just did like this...
javac <program>.java //now this worked without a problem

when i gave
java <program> //it gives the following error

Exception in "main" java.lang.UnsupportedClassVersion error
....etc etc...

plz tell me wut i should do , n why do i get such an error...

0

hey i kinda figured out a way to run simple java program (like hello world..)
set classpath=.
set path=.......\bin

but this program with packages n all wont work.. it compiles , but cant run
can someone plz tell me why???
i get the following error when i start to run with java command

Exception in thread "main" java.lang.NullPointerException

why is that?

0

My command prompt doesn't recognize neither CLASSPATH nor JAVA_HOME commands...I've already set the path variable but when i'm goiong to set the classpath and java_home variables it says that they are not recognized as an intern or extern command etc...
Could anyone please help me?

(I'm portuguese; sorry for my english...)

0

type 'set CLASSPATH' and 'set JAVA_HOME' instead. CLASSPATH and JAVA_HOME are not commands they are system varables.

(You also should have stared your own thread instead of adding onto this one.) :)

0

hi!
I have this application that runs in eclipse, but when I try running through the command prompt it gives me the above error.
the file structure is as follows
fx2b-example\src\com\reuters\example\rfa\session\ommprov\Fx2BQuoteRequest.java, there are also some java files in the following folder fx2b-example\src\com\reuters\example\rfa\session\utility.
When I use eclipse I am able to build the .class files and also execute them. class files are built in the following folder
fx2b-example\bin\com\reuters\example\rfa\session\ommprov\Fx2BQuoteRequest.class along with a bunch of other inner class files, similarly the "utility"folder I get my class files compiled into .class.
Since this program uses third party supplied api, they are located at the following location fx2b-example\src\com\reuters\example\rfa\session\ommprov\lib\.
I am using eclipse 'fatjar builder' to generate my jars, but that too gives me the same error when I type java -jar Fx2BQuoteRequest.
the same holds true for trying to run the class file from the bin folder.
What is going wrong here..
I am referring to my class as
java com.reuters.example.rfa.session.ommprov.Fx2BQuoteRequest
and its dumping the following error
Exception in thread "main" java.lang.NoClassDefFoundError: com/ubs/fx2b/liquidity/Fx2BException

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.