Java: Exception in thread main java.lang.NoClassDefFoundError
Common error that beginning java authors may experience.
- Exception in thread “main” java.lang.NoClassDefFoundError:
You try to run a little java program and you get this blasted error. I first got this error when running our little hello world program.
This occurs because the classpath is not setup or referenced correctly.
Executing your program using this command should correct the problem:
java -classpath . helloworld
where helloworld is the name of your compiled class.
This tells java that your classpath is your local directory.











LP said on October 12, 2008
Very helpful! I was stuck on this.. Thanks
Mimi said on October 14, 2008
My Classpath looks right, but I still get the error: Exception in thread “main”
.;C:Program FilesJavajdk1.6.0_01lib
Andy said on October 22, 2008
I’m sorry it did not work.
CP said on October 22, 2008
I have the same issue Exception in thread “main” java.lang.NoClassDefFoundError: any luck
v said on October 23, 2008
Just call this at the directory where you classfile XYZ.class is located :
java -classpath . XYZ
karep said on November 11, 2008
salam
didn’t work for me …
any idea ?? :’(
wassalam
Nick said on November 13, 2008
I had a problem with that, and then I noticed, that I had written”java -classpath . XYZ.class” instead of “java -classpath . XYZ” Don’t know, if this helps you, but worked for me :)
Rajesh said on November 14, 2008
the classpath should include the directory in which u r keeping ur own class files.
springrider said on November 15, 2008
Thanks a lot! It help me!
Tzell said on November 15, 2008
I am using JGrasp as a new Java learner and I hate it. The errors given when compiled to vague. Can anyone suggest a better application to begin learning and developing in?
ahmad aghajani said on December 7, 2008
My Classpath looks right, but I still get the error: Exception in thread “main”
.;C:Program FilesJavajdk1.5.0_01lib
FrederikNS said on December 12, 2008
the errors are thrown by the Sun Java Compiler, and that doesn’t differ regardless of which developer environment you try to program in, as long as it’s java, you’ll have to stick with it.
But some of the best environment to program java in would have to be Eclipse or NetBeans.
They have an awful lot of features, and is very easy to use when you get over the initial general troubles, such as which features to use, and getting an overview of all the stuff they can do.
Jim Thomas said on December 17, 2008
The above comment did not work. For newbies it may be easier to save the source files in the bin directory eliminating any path issues.
chandu said on December 18, 2008
if u have stored ur classes in the directory other than JDK installed…we need to set path to the bin dir by using
set path=…..
and for classes
set classpath=….
chandu said on December 18, 2008
we need to set two paths
1. for JDK use following command
set path=C:……
2. for classes where u compiled and kept
set classpath=D:prgrams……
grace said on December 30, 2008
you say executing your program using … pls how exactly do i execute it. i need the basic steps
Sushil Karane said on January 6, 2009
java page we get the error as follows :
Exception in thread “main” java.lang.UnsupportOperationException at sun.jdbc.odbc.jdbcOdbcConnection.createStatement(Unknown Source)
at DBConn.
at ReceiveMail.
at insertion.main(insertion.java:10)
JAaronAnderson.com said on January 6, 2009
For my CLASSPATH I have :
C:Program FilesJavajdk1.6.0_10jrelib;C:Program FilesJavajdk1.6.0_10jrebin;C:novellndkndssdkjavalibldap.jar;.;C:JavaProjectsSearchLDAPTest
Where C:JavaProjectsSearchLDAPTest is where my List.class compiled class resides
I also created JAVA_HOME Variable for my user with a value of:
C:Program FilesJavajdk1.6.0_10
and finally I have for my Path:
C:Program FilesJavajdk1.6.0_10jrebin;D:Program FilesSSH Communications SecuritySSH Secure Shell;C:Program FilesJavajdk1.6.0_10binjavac.exe;C:novellndknjclv2rsrcnjcl
Which C:Program FilesJavajdk1.6.0_10jrebin is the bin of the RUNTIME or should I also list C:Program FilesJavajdk1.6.0_10bin :: the JDK bin/ instead ?
anyone with any CLEAR ideas ? thx
Abhhilash said on January 11, 2009
I have created the hello world program and i am using textpad to do that
My program is compiling but when i run it gives me an error
java.lang.NoClassDefFoundError:
Exception in thread “main”
Tool completed with exit code 1
I have set my path to C:jdk1.3bin
and the classpath to where the program reside but in vein can anybody help
irene said on January 16, 2009
noooooo…. i have tried it all…. :(
it keeps saying that java.lang.noclassdeffounderror thing…
Nathiya S said on January 23, 2009
how do create path to j2sdk1.4.2_02
i run small prgm, my error is
exception in thread “main” java.lang.noclassdefFoundError
how do clear my error
Rakesh said on January 27, 2009
Thanks great info
Martin said on January 28, 2009
I had the same problem. It turned out the cause was that I tried to compile a java sample file from a read-only folder.
When I copied the .java file to my hard drive the problem went away
abhishek said on February 3, 2009
Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:Usersmdube>cd
C:>javac C:abhishekMohit.java
C:>java C:abhishekmohit
Exception in thread “main” java.lang.NoClassDefFoundError: C:abhishekmohit
C:>java C:abhishek/mohit
Exception in thread “main” java.lang.NoClassDefFoundError: C:abhishek/mohit
C:>javac C:abhishek/Mohit.java
C:>$Recycle.Bin
‘$Recycle.Bin’ is not recognized as an internal or external command,
operable program or batch file.
C:>JAVAC
Usage: javac
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are us
ed
-classpath Specify where to find user class files
-sourcepath Specify where to find input source files
-bootclasspath Override location of bootstrap class files
-extdirs Override location of installed extensions
-d Specify where to place generated class files
-encoding Specify character encoding used by source files
-source Provide source compatibility with specified release
-target Generate class files for specific VM version
-help Print a synopsis of standard options
C:>JAAVA
bothanks said on February 6, 2009
omfg ahmad aghajani ,
i o u big!!!
ty for suggesting at putting that in the Class path file, a program of mine has been corrupted for over 2 yrs, and i tried to fix it 1 last time, and ur suggestion worked!!
ty!!
stacy said on February 8, 2009
try netbeans
Amruta said on February 12, 2009
Thank you!! It really helped me.
i just copied my files in bin dir. try doing this.
Amruta said on February 12, 2009
if After setting the path also it doesnt work.. save all files in bin dir and run the prgram using that path.
Neicey said on February 16, 2009
Here is how i fixed mine.
The .Java and the .Class file is located in C:Java . i got the above error and changed directory at the dos prompt by typing
cd Java (Enter)
Then I compiled by typing the below
C:Java>”C:Program FilesJavajdk1.5.0_16binjavac.exe” C:javasaluton.java
Than I run by typing the below
C:Java>java Saluton
Results …
Saluton Mundo!
Hope this Helps . Arichards
Sham said on February 17, 2009
Thanx a lot very usefull!!
sad said on February 23, 2009
After doing the following….where m is my class name
java -classpath . m
i get this……..
Unrecognized option: -classpath.m
Could not create the Java virtual machine.
help is appreciated!!!1
harpreet said on February 25, 2009
thank you it really helped me
The One said on February 26, 2009
Ha! I figured it out! I just wasn’t compiling every file! “javac *.java” fixed it all! YES!!
Gary Lesperance said on February 26, 2009
I had the same problem but your suggestion above did not work. You missed the most obvious problem which is that Java is case sensitive. If you reference the class as Helloworld in the script and then try to run it using java -classpath . helloworld (with the file actually named helloworld.class) then you will get the same error referenced above. The problem is the upper case “H” in the script and then the file starting with a lower case “h”.
nice said on February 27, 2009
hi to all
too , i have error :
Exception in thread “main” java.lang.NoClassDefFoundError: nameclass
help me.
Crimson said on March 10, 2009
hi guys,
I got this error when i made the mistake of running the class file. Make sure you are running the job correctly (fyi, I’m running vista):
Correct: C:UsersCrimsonteaching> java Example
Incorrect: C:UsersCrimsonteaching> java Example.class
This is really easy to forget about, especially if you’re used to using an IDE like Eclipse, which was the case for me. I scratched my head for a little while and feel really dumb now.
GXOne said on March 10, 2009
OMG Thankyou After 5 Hours Thankyou.. with that advice it all works exactly the way it should LOL
techno said on March 12, 2009
i think you are not giving space between the classpath n dot n m…
like java -classpath[space].[space]m
mine was also having the same error but when i gave spacing between them it worked,,..so u can also try dis once…
desperado said on March 24, 2009
i used textpad and i still got the same error, can anyone tell me what’s wrong?
desperado said on March 24, 2009
thanks techno, great advice!
Thomaso said on March 31, 2009
Thanks sooo much. if the java – classpath . helloworld doesnt work it is probably due to spacing and upper lower case letter problem.
for me i didnt put a space after java and a space either side of the full stop. and i forgot to write my class with an upper case letter which is how it was saved.
java(space) -classpath(space) . (space)Welcome1
jango19 said on April 6, 2009
Exception in thread “main” java.lang.NoClassDefFoundError: Receiver/class
Caused by: java.lang.ClassNotFoundException: Receiver.class
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: Receiver.class. Program will exit.
where Receiver is my class..code is getting compiled perfectly but when i run its givin the above error..
Anonymous said on April 6, 2009
hello ,i got a problem while executing a sample java program.
error is java.lang.NoClassDefFoundError: and im using jdk 1.6 version .
someone helpout this
aravind said on April 17, 2009
thanq very much for giving the solution…….
nabil said on April 29, 2009
Awesome.
It worked great
Anonymous said on April 30, 2009
Awesome dude thanks this solved my problem..I used to think that java.exe compiles and executes the application but I gues I was wrong….
Ram said on May 14, 2009
Hi ,
First set the JAVA_HOME variable with your bin directory.
then try to run .it will help u.
Regards
Ram Yadav
hello said on May 19, 2009
hey im not trieng to program a file or anything like taht. im just trieng to play a private game server and i keep getting the error message Exception in thread “main” java.lang.nodeffound: joader i have no idea how to fix it can anyone help? my CLASSPATH is C:Program FilesJavajdk1.5.0_18bin; and my PATH in C:Program FilesJavajdk1.5.0_18bin
anyone help?
hello said on May 19, 2009
hey this is me hello again and please dont post anything too confusing i have no knowledge of java except for classpath and path so please keep it simple
hello said on May 19, 2009
and instead of joader its loader sorry for that
Kieran Taylor said on May 25, 2009
!!ALERT!! !!ALERT!!
I just followed every suggestion in this string and no dice…
FINALLY I GOT IT —-> (on Windows XP) MAKE SURE YOU COMPILE YOUR PROGRAM WITH C:…javac ClassName.java before you try to execute with C:…java ClassName
You will know your program is compiled when you find a ClassName.class file in the same folder as your original ClassName.java program.
Hope this helps the last desperate few.
And yes, of course, make sure your path and classpath are correctly configured.
Loser said on May 25, 2009
Worked for me !!!
sixlead said on May 25, 2009
You will also get this error if you append the .class designator when you try to run it. as
java HelloWorld.class
java is expecting a class so the .class suffix is not necessary
of course your class path might be wrong also ;-)
Anonymous said on June 17, 2009
Does not work
Ian said on June 19, 2009
Thank you – this is so helphul for me at the moment
If you are also dependent on a jar file in the same folder you may need to have something like
java -classpath .;./dependent.jar helloworld
Su said on July 3, 2009
Your advice point out what I missed. Thz alot techno.
rahul agarwal said on July 4, 2009
thanks for the replies that have been posted….
i am so glad that my problem has been solved…
Name said on July 21, 2009
THANK YOU! My God this problem was so annoying
Anonymous said on July 23, 2009
Gret thank you. I had the problem with the simplest program and the code was published on a book so I thought there can be nothing wrong with it.
THANK YOU again :)
vazeer said on July 25, 2009
Thank You it really worked for me
Anonymous said on July 27, 2009
That worked! Thanks a lot,
It would probably help if you explicity indicate that the extension “.class” should not be used when using “-classpath” .
Anonymous said on July 27, 2009
Ops, should’ve read the above comments first!
my bad.. lol
Anonymous said on July 30, 2009
Well, I’m currently making my own chatserver in java, and when i compile with cmd, i get this error. Any help? I’m using the guide on Hello World on compiling and making classes.
Anonymous said on August 6, 2009
for coming out from this type of error
we can run the programm by using diffrn style..
like
java -cp . className
Anonymous said on August 7, 2009
It might be due to packages.
Try removing any “package” from the top of your *.java files.
Anonymous said on August 13, 2009
I am getting the class path error.My XYZ.java compiles good..When i run the program i and getting the below error..
I had set the Classpath for the dependency jar and the Java_HOME = C:Program FilesJavajdk1.5.0_20bin
C:Program FilesDDEForJavaexamplescomjavapartsddeexamples>java -cp . Excel
Async
Exception in thread “main” java.lang.UnsupportedClassVersionError: ExcelAsync (U
nsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
Any help would be appreciated//
Thanks
Shelli
Anonymous said on August 14, 2009
this happening 2 me, now i cant play a runescape private server thats 508, help me please?
b00red said on August 16, 2009
i don’t understand this ‘Executing your program using this command should correct the problem:
java -classpath . helloworld’ ?
where / how do i execute with another classpath?
Hamhama said on August 17, 2009
For a beginner you may get this error also if you run:
java helloworld.class
Instead try to run:
java helloworld
Anonymous said on August 19, 2009
Okay, here’s the mistake I made (which almost drove me crazy):
set classpath = .;M:;C:Program FilesJavajre1.6.0_14bin;
is NOT the same as:
set classpath=.;M:;C:Program FilesJavajre1.6.0_14bin;
If you put spaces around the ‘=’ it won’t work. The file would always compile but would only run without the package designation. As soon as I added the ‘package’ statement at the top I could compile it but it would always give the above error when I tried to run it. Hope this helps someone.
Anonymous said on August 23, 2009
C:javaprog>java HelloWorld
Exception in thread “main” java.lang.UnsupportedClassVersionError: HelloWorld (U
nsupported major.minor version 50.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
C:javaprog>
Anonymous said on August 26, 2009
No, java -classpath . helloworld did not work. What next?
Anonymous said on August 27, 2009
Thanks, It helped
Ankzz said on August 27, 2009
It works.. One needs to pay heed to what has been said… Follow it step wise and U wont get any error
Anonymous said on September 11, 2009
superb information. excellent !
Anonymous said on September 16, 2009
Hi every one.
I have installed red5 server on my machine and also JDK version of 1_5_0_11
java -classpath C:Program FilesRed5red5.jar F:Video Chatred5chatv2.1JAVA-RED5srcchatapplication.java
but when I tryed to compile to get my application.class file using above shown command on command promt I got error : Exception in thread “main” java.lang.NoClassDefFoundError: FilesRed5red5/jar
Anonymous said on September 21, 2009
thnx…great work buddy.It solved the problem for me.thanks a lot.
Anonymous said on September 22, 2009
Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/xml/serializer/TreeWalker
at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:823)
at com.pg.EDICustomize.EDISplit204.generateTarget(EDISplit204.java:353)
at com.pg.EDICustomize.EDISplit204.execute(EDISplit204.java:99)
at com.pg.EDICustomize.EDISplit204.main(EDISplit204.java:392)
Caused by: java.lang.ClassNotFoundException: org.apache.xml.serializer.TreeWalker
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
… 4 more
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
i got this error please help me to resolve this
Kevin said on September 27, 2009
I had this issue on linux. Turned out it was simply that the path had a space in it. When this was changed it worked fine.
Anonymous said on October 14, 2009
is it a problem of program?.
Anonymous said on October 27, 2009
how do you execute it with THAT command? like what do you do? where do you type that in (java -classpath)?
Anonymous said on October 28, 2009
Ya, I’ve read all of these comments and have no clue where to type the java -classpath . XYZ
Anonymous said on November 4, 2009
Thanks … this works for me… I have been seem this type before but I was typeing ‘.’ close to ‘-classpath’ …
Anonymous said on November 6, 2009
thanks a lot it was really heplful..
Alan said on November 13, 2009
I just started learning java using the Eclipse IDE. My java for idiots book (ok for dummies) gave me some code that uses swing to produce a message box. There are 2 classes (the book is demonstrating objects).
It ran fine from within eclipse, but if I tried running it from a command line it wouldn’t work. I got the java.lang.NoClassDefFoundError.
I’ve searched the net and tried the -classpath . approach and still had no joy.
I then found a post here
http://bytes.com/topic/java/answers/15627-java-lang-noclassdeffounderror#post63668
which refers to the package name as being an issue. I tried following the instructions but still had the issue. Eventually I removed the package definition from both my source files, recompiled and it runs fine. No classpath definition needed.
Cheers
Alan
W00t !
neusbloed said on November 16, 2009
Crimson you finally made me understand why I was doing it not properly. I use Eclipse too. I’m going to feel really dumb now but I’m really happy I can run my files.
Anonymous said on November 18, 2009
yes.. a dot .. it means, that it will search for classes bytecode in the current directory !
you can also tell java to search the current directory with the -classpath parameter
> java -classpath . Hello
Problems like this can really discourage java newbies, and that moment was very embarassing :)
Setare said on November 27, 2009
thank you for your help in solving this java error.
Anonymous said on December 3, 2009
There are many correct answers here but not really clear to a java noob like me. After pulling my hair out for an hour and reading the answers over and over again it finally struck me.
The answer for me is this: You should give the path to the directory where your to be executed .class file is, from the directory where you execute it from as you classpath.
/program/Java/$: Javac hello.java
/program/Java/$: java hello
Hello!!
If i now want to execute it from /program
/program$: java -classpath ./Java hello
Hello!!
or from the root /
/$: java -classpath ./program/Java hello
Hello!!
Hope this makes sense for the ones who did not get it the first ten times like myself.
Anonymous said on December 17, 2009
Thanks! this was helpful for me to resolve a pestering issue!
kiran said on January 5, 2010
while intepreting a program in java dont put .java after class name otherwise u will get (thread “main” java.lang.NoClassDefFoundError:)
Anonymous said on January 13, 2010
following is my simple awt program it get compile successfully
but during run it generates following error
Exception in thread “main” java.lang.NoClassDefFoundError: sampleframe (wrong na
me: components/sampleframe)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Anonymous said on January 13, 2010
pls pls help me
Chitre Mangesh said on January 16, 2010
HI Everyone .
Following should be checked:=
Primary check for java -version, if it returns values then installation is proper else re-install
(Installation path may vary… check yours accordingly …..)
1)Set JAVA_HOME to C:/Program Files/Java/jdk1.6.0_12
2) Set CLASSPATH environment to C:/Program Files/Java/jdk1.6.0_12/jre/lib;./;
(Note :- ” ./ ” )
3)Set Path to C:Program FilesJavajdk1.6.0_12bin
Banananana said on January 24, 2010
If the class you wanna execute is in a package, do this:
java -classpath . packagename.classname
Don’t forget the spaces after “classpath” and the first “.” and note that there aren’t spaces after your package name and the following period.
asif said on February 4, 2010
Yes it worked in eclipse!! thanks.
Anonymous said on February 8, 2010
hey bro’s thnx it solved my issue
Anonymous said on February 8, 2010
im getting the error java.lang.NoClassDefFoundError:
my classpath is c:jdk1.5lib.
give me a help pls
joe said on February 15, 2010
alright, im pretty much haveing the scape problem as every1 else but, im such a newb to using computers… my problem says “NoClassDefFoundError:” how the HECK do i fix it???
joe said on February 15, 2010
haveing=having and scape=same (sry typos)
Anonymous said on February 16, 2010
thank you soooooo muchhhhh!!!!!! this comment has helpd me sort out a problem that i wasn’t being able to do for days!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! i tried doing everything possible, including setting path & classpath variables, but nothing helped……. thank u so muchhhhhh!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Anonymous said on February 17, 2010
i finally got it….
first set the CLASSPATH to the location of the folder where you have saved the .java files.
second, make sure that in the PATH, you got a setting describing where the installation files are- i.e C:Program Filesjavajdk 1.6.0_18bin.
also ensure you got QTJAVA set to the location of the jre bin file-i.e c:program files.
lastly, create a variable called JAVA_HOME containing the following values….the location for the jdk bin. I.E c:
ALL THE BEST IT WORKED FOR ME
iedoc said on February 19, 2010
WOW! finally! that was it, just don’t put the extension on it! damn, thank you!
Anonymous said on March 5, 2010
hi,
how can i run a java program by cmd in winxp
for example ,
a java pgm compiled and got the class file
pgm name=hello.java
D:javac hello.java===got the class hello.class in D: drive i copied that class file the paste in E:
then how i run the pgm from D:
D:java -cp E:hello
but hitting enter java.lang.NoClassDefFoundError: this error is comming
what is the problem please help me
Anonymous said on March 5, 2010
the problem was i didnt put space
D:java -cp E: *hello
the * is the space i forgot
This may help other
Nitin said on March 9, 2010
Thanks.. was helpful..
Al said on March 10, 2010
I had this problem and this suggestion did not work.
I figured out that when you have, lets say a class called X, and at the top of the java file it does NOT have a package statement, the class will compile and run with javac and java with no problems.
When you add a package statement and try to run the program with the line java X, it fails to run.
You must go to the parent directory of the package directory and run the line
java .X
This works perfectly fine and solved my problem.
Hope this helps!
Anonymous said on March 10, 2010
Everywhere I look I see the classpath as an issue but even though I got the same error, classpath was not the problem.
If you know your classpath is set up right check you source file. In my case, I had named my class one thing and tried to run it with the name I thought I had called in the source.
For example, my source said class VolcanoApplicataion when I mean VolcanoApplication so when I compiled it went fine but when I tried to run it as the name i truly meant I got the error in question.
Hope it helps and spread it around cause everywhere I looked left out this tidbit
Andrew Witherspoon
Anonymous said on March 11, 2010
Thank u so much . Your idea helped me a lot .
Anonymous said on March 12, 2010
Don’t forget your classname is CASE SENSITIVE.
Here’s how I do it:
Open CMD.
(I keep my files in Documents)
cdusersdubedocuments
set PATH=%PATH%;C:Program FilesJavajdk1.6.0_03bin
javac SampleProg.java
java SampleProg
That’s it. CASE SENSITIVE.
Pranav said on March 21, 2010
yp it helped me too
Anonymous said on March 29, 2010
Hey chandu thanks a lot it worked out for my final yr project thanks a lot once again :-)
Marin van Zandvoort said on April 5, 2010
Many thanks!
I almost give up, but then I found your short-and-really-to-the-point answer to the problem.
Anonymous said on April 14, 2010
Although I’ve read through all of the postings here and elsewhere & already tried all of those recommendations and re-installing the Java JDK, I keep getting the error of NoClassDefFoundError.
Also, following various changes I made to suit the recommendations listed about this problem and possible solutions, my PATH, Java_HOME, and Classpath variables are set to the following:
a) PATH system variable:
%SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;C:Program FilesMicrosoft SQL Server90Toolsbinn;C:Program FilesCommon FilesRoxio Shared9.0DLLShared;C:Program FilesCommon FilesRoxio SharedDLLShared;C:Program FilesQuickTimeQTSystem;C:Program FilesJavajdk1.6.0_19bin
hared;C:Program FilesCommon FilesRoxio SharedDLLShared;C:Program FilesQuickTimeQTSystem;C:Program FilesJavajdk1.6.0_19bin;C:Program FilesPalmSDK
bin;C:Program FilesPalmSDKbinnovacom
b) Classpath:
.;
c) Java_Home:
C:Program FilesJavajdk1.6.0_19
Also, in Eclipse, I have the “helloUser” class stored in a package named “HelloUser” and am running Vista with the User Account Control feature disabled. In addition, when using the javac command with the helloUser.java class from the C:users[myName]workspaceHelloUsersrchelloUser directory, it appears that the helloUser.java class gets compiled successfully. The problem appears to be isolated to using the java command against the compiled version of the class.
Any thoughts?
Errors shown when trying to execute the class from the command-line:
————-
c:Users[myName]workspaceHelloUsersrchelloUser>java HelloUser
Exception in thread “main” java.lang.NoClassDefFoundError: HelloUser (wrong nam
: helloUser/HelloUser)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: HelloUser. Program will exit.
Anonymous said on April 21, 2010
the
Anonymous said on April 21, 2010
thing
Anonymous said on April 23, 2010
alert(‘hi’)
Anonymous said on April 23, 2010
good
Anonymous said on April 23, 2010
nice
Anonymous said on April 24, 2010
there is a exception error in swing
Anonymous said on April 29, 2010
I use windows 7, I know nothing about java. I’m trying to compile a script into this program/application using the ‘Compile-Scripts.bat’ thing that’s in the folder. when i click to compile it i get this message.
Exception in thread “main” java.lang.No.ClassDefFoundfError: Scripts/ErrmmPwwndpapayas/java
Caused by: java.lang.ClassNotFoundException: ScriptsErrmmPwwndpapayas.java
at Java.net.URLClassLoader$1.run
at java.security.AccessController.doPrivileged
at java.net.URLClassLoader.findClass
at java.lang.ClassLoader.loadClass
at sun.misc.Launcher$AppClassLoader.loadClass
at java.lang.ClassLoader.loadClass
at Java.lang.ClassLoader.loadClassInternal
Could not find the main class:ScriptsErrmmPwwndpapayas.java. Program will exit.
Press any key to continue. . .
I have tried really hard to read and understand/comprehend all the great information in this thread and other, but I am still unable to understand how to fix anything.
If someone has yahoo messenger and can help me that’d be awesome. I could show you the folder and stuff with screen shots and maybe you could tell me what to do.
potterman210@yahoo.com
Anonymous said on April 29, 2010
This is what the ‘Compile-Scripts’ bat looks like, hopefully it will help
@ECHO OFF
TITLE RSBot Scripts
SET cc=java
SET cflags=
SET scripts=Scripts
SET scriptspre=%scripts%Precompiled
SET jarpathfile=Settingspath.txt
IF NOT EXIST “%jarpathfile%” (
ECHO Path file does not exist. Please run RSBot and try again.
GOTO end
)
FOR /F “delims=” %%G IN (%jarpathfile%) DO SET jarpath=%%G
CALL FindJDK.bat
IF NOT EXIST %scripts%*.java (
ECHO No .java script source files found.
GOTO end
)
ECHO Compiling scripts
ECHO. > “%scripts%.class”
DEL /F /Q “%scripts%*.class” > NUL
“%cc%” %cflags% -cp “%jarpath%” %scripts%*.java
:end
PAUSE
EXIT
Anonymous said on April 30, 2010
if you have defined a classpath then go to that location and execute the pgm, else you should not be having problems
Anonymous said on May 2, 2010
What does that mean?
Anonymous said on May 16, 2010
thank you!!
Dhiroj said on May 21, 2010
many many thanx
really a helpful data
Anil said on May 26, 2010
There is nothing problem just set the JAVA_HOME path and PATH of java installation folder.
default path of JAVA_HOME is C:Program FilesJavajdk1.5.0
and PATH is C:Program FilesJavajdk1.5.0bin
above all this, set in environmental variable in my computer.
Jenefar Esther04 said on June 16, 2010
its very useful to me.thanks
Renuka salavi said on June 23, 2010
i used this still i found the same error
Exception in thread “main” java.lang.NoClassDefFoundError: menu (wrong na
u)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.
4)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Michael said on June 23, 2010
THIS THIS THIS, finally. I’ve been trying to fix this for a while and this was exactly the solution I needed.
Pandian said on June 24, 2010
thank u very very much…. the spaces helped me a lot….
Fr said on June 28, 2010
Man.. Thanks ! I was stuck on this for like 2 hours :D
Somedude said on June 28, 2010
Thanks Nick, I feel silly….
HugeIdea said on June 30, 2010
You should miss the .; in front of your classpath. add those to your classpath, and it should work fine.
Ollan_misa said on July 2, 2010
wath path i can use in window 7???? tnx im stuck doing my home work :/
Ds said on July 9, 2010
Solution is:
Hi there,
Problem often occurs when re?nstalling, easy to fix: i right-click on my computer, Properties, select the Advanced Tab, then press the Environment Variables button and a window pops up. At the bottom there’s is a button with System Variables, press it. All you have to do is delete CLASSPATH variables in the list.
Svsreddy01 said on July 15, 2010
Exception in thread “main” java.lang.NoClassDefFoundError
this error will occur wat i do plese give me answer
Mahrizal said on July 25, 2010
thanks , it usefull for me
thanks a lot
Aa said on July 27, 2010
Thanks Al !! This is what I looked for!!!
Live_long6 said on July 30, 2010
My class path is proper….even i am getting .class file…but it show me java.lang.noclassdeffounderror error plz help me thxs..
Suntro2007 said on July 30, 2010
After a full day of research I could find the solution to the problem.
I created a java program Pet.java under a package com.xyz.client under the folder sturcture
C:Documents and SettingsspatroWorkspacespositronmyProjectsrc
so my Pet.java resides in
C:Documents and SettingsspatroWorkspacespositronmyProjectsrccomxyzclient
I set my classpath to C:Documents and settingsspatroWorkspacespositronmyProjectsrc
by doing set CLASSPATH=%CLASSPATH%;C:Documents and settingsspatroWorkspacespositronmyProjectsrc
to compile the program
I changed to the directory where my Pet.java resides
so I did
cd C:Documents and SettingsspatroWorkspacespositronmyProjectsrccomxyzclient
and there I executed the command
javac Pet.java
and then I switched my directory to
my src folder where my package reside i.e
C:Documents and settingsspatroWorkspacespositronmyProjectsrc
and here I executed the command
java -cp . com.xyz.client.Pet
Note:- the . is for the current directory.
Hope, this explanation will help others who struggled for this like me.
Reeteshdas said on August 2, 2010
the above solution does not solve the problem.
Nehadhmn said on August 5, 2010
o god!!!! u’r my savior!!!! so dis was it!! i was using d extension along…. o gosh… thnx a lot!! thnx a million crimson!!! mmmuuaahh!! thnx a lot!!
Conor said on August 13, 2010
Holy crap! Worked like a charm!
naveen said on August 13, 2010
thanks a lot abdul, i have been trying to solve this problem for 7 hrs !
finally i got the solution
Shg23 said on August 27, 2010
I solved that callin my program without .class extention
Nvenkat Ede said on August 28, 2010
what is the permanent sol for java.lang.NoClassDefFoundError Exception without writing -classpath explicitly when ever we have to run the .class file
Girish0204 said on September 11, 2010
When I execute hello.java i am getting the following error:
C:>java HelloWorld.java
Exception in thread “main” java.lang.NoClassDefFoundError: HelloWorld/j
Caused by: java.lang.ClassNotFoundException: HelloWorld.java
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: HelloWorld.java. Program will exit.
Note: I have installed Java under C:Program FilesJavajdk1.6.0_21
Not sure what is the problem. Please help
Is there any problem in setting the path and class path?
Anonymous said on September 15, 2010
Helped me a lot
Venkatesh Marni said on September 20, 2010
set classpath=.; in command prompt
Fredd said on September 22, 2010
Debes de asegurarte que el .class se este guardando en el directorio actua
Silver_manta said on September 23, 2010
Thanks so much!!!!
husy said on October 4, 2010
hmm
Veb_405 said on October 6, 2010
thank u very much to solve my problem
Awoo100 said on October 13, 2010
What a deuchebag why didnt I think of this!
Priyadarshini said on November 5, 2010
Hey adul,
this really worked.
May i know why this happens?
When i execute the program using java classname
i get Exception in thread “main” java.lang.NoClassDefFoundError: classname.
However when i executed using java -cp . classname it really worked.
Reason please.
Lindsay said on November 13, 2010
I’m using RMIC to generate a stub, but I keep getting ClassNotFound exception. Some code works and some code doesn’t. The code works on my partner’s computer, not mine, PLEASE help. I can get the RMIC to work by specifying -classpath, but I can’t use the dot to specify the current directory and my server fails to start up.
Mail2yugi said on November 14, 2010
thanks its working
Sarav Preet Singh said on November 15, 2010
very very thanx
Catony said on November 16, 2010
Thanks Ds, this really solved my problem for good. There was another CLASSPATH variable listed–hope my deleting it won’t screw up that program.
I’m using TextPad which would compile my program fine but not run it without that stupid error, and it was a bother to go to the DOS command prompt to run the program using “java -classpath . Classname” though that did work too.
Thanks everyone, I’m hoping to stick with it.
vineet said on November 19, 2010
i’m srry
it didn’t work
when i compile my program, it compiles successfully but when i run the command
java -classpath.A
it shows :
unrecoginzed option: -classpath.A
couldnot create the java virtual machine
Amit said on November 25, 2010
it’s really helpfull..
Thanx
Utkarsh said on November 25, 2010
not working yet
Amara said on December 1, 2010
This is the error thats troubling me :
Collapse
C:Documents and SettingsxxxxDesktopJava Files New>javac MSWord.java
C:Documents and SettingsxxxxDesktopJava Files New>java MSWord
Exception in thread “main” java.lang.NoClassDefFoundError: MSWord (wrong name: o
rg/jinterop/dcom/test/MSWord)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: MSWord. Program will exit.
Environment Variables:
JAVA_HOME C:glassfishv3jdk
CLASSPATH .;C:Program FilesQuickTimeQTSystemQTJava.zip;C:Documents and SettingsxxxxDesktopj-Interoplibj-interop.jar;C:Documents and SettingsxxxxDesktopj-Interoplibjcifs-1.2.19.jar;C:Documents and SettingsxxxxDesktopj-Interoplibj-interopdeps.jar;C:Documents and SettingsxxxxDesktopj-InteroplibprogIdVsClsidDB.properties;C:glassfishv3jdkbin;C:Documents and SettingsxxxxDesktopJava Files New;C:glassfishv3jdklib;
Path %SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;C:Program FilesQuickTimeQTSystem;C:gwt-2.1.0;%ANT_HOME%bin;C:Program FilesJavajre6bin;C:glassfishv3jdkbin;
Details:
Installed Java(TM) 6 update 22
Java(TM) 6 update 5
C:Program FilesJavajre1.6.0_05
C:Program FilesJavajre6.0
C:glassfishv3jdk
Tools.jar is present in all the lib and bin folders of the above locations.
Tried all these:
http://www.tech-recipes.com/rx/826/java-exception-in-thread-main-javalangnoclassdeffounderror/^]
http://www.jguru.com/faq/view.jsp?EID=455768&page=1^]
Nothing has resolved my issue, i am new to java and very confused on whats happening!! I knew the error is with classpath but i have tried all possible combinations.
Any suggestions or advices!! Please let me know if you need any more info!!
Amara said on December 2, 2010
I got it resolved when i used
C:Documents and SettingsxxxxDesktopJava Files New>java org.jinterop.dcom.test.MSWord
Rahmadhany T said on December 8, 2010
Make sure you already set you CLASSPATH environment variable.
Read this section carefully:
Understanding the class path and package names
on http://download.oracle.com/javase/1.3/docs/tooldocs/win32/classpath.html
I assume you already knew about package concept in java.
Vin said on December 11, 2010
Thanks Thomaso.. it worked.. !!
Sowmya said on December 12, 2010
Exception in thread “main” java.lang.NoClassDefFoundError: jomp/compiler/jomp
i get this error wen i try to compile a simple helloworld.jomp file as
java jomp.compiler.jomp helloworld
m using jomp1.0b i have also set the class path n path
can anyone tell me y i get this error
ANIMEMANIX said on December 31, 2010
were do i write that,
im making a rs server
wat is a classpath? lol
Duckiesgrandpa said on January 1, 2011
I just learned that Capitalization is also important. If your class file is named HelloWorld then helloworld won’t work.
Chap said on January 1, 2011
Starting L2J Game Server.
Exception in thread “main” java.lang.NoClassDefFoundError: com/l2jserver/gameser
ver/GameServer
Caused by: java.lang.ClassNotFoundException: com.l2jserver.gameserver.GameServer
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: com.l2jserver.gameserver.GameServer. Program wil
l exit.
Server terminated abnormaly
server terminated
Press any key to continue . . .
Manish said on January 25, 2011
Hi guyz I am looking for a program which print everytime on pressing enter Hello using the thread in Java
Manish said on January 25, 2011
can anyone tell me how we can write a program to open an internet explorer in Java
who885 said on January 25, 2011
hey guys im having alot of troublel latly im trying to make a rsps but i keep getting this errore
Exception in thread “main” java.lang.NoClassDefFoundError: client
Caused by: java.lang.ClassNotFoundException: client
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: client. Program will exit.
Press any key to continue . . .
if you can help great
P4_pacific007 said on February 3, 2011
when I compile a simple prog it points error towards the dot between
system.out as in system.out.printin()
Sumsin123 said on February 4, 2011
by default CLASSPATH is always current directory. Setting up CLASSPATH variable explicetely overrides this value
Nk3527 said on February 12, 2011
i have found error “Exception in thread “main” java.lang.NoClassDefFoundError” when i was tring to execute my own packages.What is solution
ravi kiran naidu said on February 13, 2011
it’s working i liked it
srileo said on February 17, 2011
set environmental variables first…
Chitra_12 said on February 22, 2011
When im executing the simple java program ..
i get
Exception in thread “main” java.lang.NoClassDefFoundError: classname.
Chitra_12 said on February 22, 2011
what commands should give now if help me
Chitra_12 said on February 22, 2011
its System.out.println()
first character ’s’ should be in uppercase
Raymond said on February 24, 2011
Sorry, i also face this problem.
I not really know bout java.
What mean of set environmental variables?
got example?
alien said on February 24, 2011
this is great. thank you very much.
my problem was the missing ./ in CLASSPATH
Deathdragon6 said on February 28, 2011
no lib C:Program filesjavajdk1.6.xxxxxbin
Anonymous said on February 28, 2011
Thanx ……….this worked !!!!!!!!
L_savitha said on March 1, 2011
Can any one suggest me how to proceed with this. i tried all possible methods.
On clicking on one button, it should print on the console. it should keep printing until another button is pressed
Luis Adrián Ferreyra said on March 2, 2011
THIS IS A MESSAGE FOR EVERYONE WHO STILL HAVE THIS PROBLEM
I’m sure you’ve tried everything written in this forum. After looking for an answer at Oracle’s website, I’ve finally found it.
WHAT YOU’VE GOT TO DO is to stand in the src folder of your proyect, NOT IN YOUR PACKAGE. then, use this syntax:
java -cp . PACKAGE.CLASS
remember, your cd must be your proyect/src and follow the syntax above.
Chiragpatel said on March 6, 2011
just put .; in ur class path and it ll work
this is message from GOD
Chiragpatel said on March 6, 2011
.: period semicolon
TomDh said on March 7, 2011
Thank you. This was what i was looking for.
in commandprompt go to the global path of your application:
d:applicationsmyApplicationbin
execute your application
d:applicationsmyApplicationbin>java -cp com.package.model.myClass
change the JAVA_HOME to
d:applicationsmyApplicationbin
Imran Sharif said on March 7, 2011
i have a problem
build.xml for jboss aop has an error
“” Exception in thread “main” java.lang.NoClassDefFoundError: org/jboss/util/file/ArchiveBrowser$Filter “”
can any body plz help what s the problem ???
Magnus said on March 9, 2011
Apparently it matters in which order you put the class-files when creating your jar-file. If you’re using superclasses/subclasses you have to put the superclass first in the command! Like so: “jar cvmf manifest.txt myfile.jar SuperClass.class SubClass.class TestClass.class”
Onkdurga said on March 11, 2011
It is very nice…gives the solution exactly
vinay singh said on March 15, 2011
Hey hi well i m trying to run a simple prog that having a object of another class but it is giving error the symbol not found evn the class file is in same directory………
awsmvini said on March 15, 2011
hello help me out plz ……..m tryng to run a java prog which is having connectivity with mysql i pasted the driver in javalibext folder evn its is giving error that driver not found exception in main………
Rajroy 002 said on March 15, 2011
sep path
Rybka2323 said on March 19, 2011
omg… nothing work ;( what i need to do!? HELP!!!!!
C Bala86 said on March 25, 2011
I got this error in my eclipse. I found there was class file getting generated for the project. Reason was no default java builder defined for the project.Opened the .project file and added the default java builder definition. Now it works fine
C Bala86 said on March 25, 2011
Sorry class file was not getting generated previously
Jagadish_t said on March 25, 2011
This was really saved my problem. I changed the CLASSPATH variable to add the current directory. Which is “.”, This saved me my life. Thanks for the valuable post.
dhruv said on March 30, 2011
thank u sir thank u , u saved my receding hairline
Popujari said on March 31, 2011
setting path till again give same error no class deffound
Pam said on May 13, 2011
Hi I have this error in my loginserver Exception in thread “main” java.lang.NoClassDefFoundError: LOGIN_HOSTNAME i need help , what should I add in my CLASSPATH?
M Bhagyabhushan said on May 22, 2011
frustated wit this problem and got solution
Kaucuk said on May 29, 2011
Watch out the case sensitivity like class hello, file hello etc
yeyeye said on June 20, 2011
waw, thanks very much! You are really helpful! Your recipe is delicious! LOL
JP@ classpath in Java said on July 17, 2011
nice recipe. I also found this link quite useful
3 ways to resolve NoClassDefFoundError in Java
JP@ classpath in Java said on July 17, 2011
nice recipe. I also found this link quite useful
3 ways to resolve NoClassDefFoundError in Java
Shawna said on July 22, 2011
omg i have been working on this FOREVER and none of the many suggestions worked. But first i should tell you that every single step I had huge problems but I never gave up because I have successfully configured a few years ago when I first tried to teach myself Java. Anyway, I have made many mistakes configuing the CLASSPATH so I really didn’t know what to fix. After finally getting it to compile successfully (creating the class file) it still wouldn’t work. Finally I tried this…and I didn’t see it anywhere in this blog so I hope it helps everyone after me. In addition to what you have in the CLASSPATH (int the envir. varables)add the following without deleting anything you already have there:
.;C:J24work
instead of J24work you should enter the exact path to where you are puting you .java and .class files which is probably different from where you JDK is for some people.
I truly hope I explained this well and it helps someone.
madu said on August 21, 2011
how to get only two precision after decimal in java..eg.3.8989E-34,MUST BE MADE TO 3.89
Anthony said on August 23, 2011
Thanks so very much for this simple and clear solution.i had set all variables and did a lot of copying from one directory to another but to no avail until i issued this simple command and it ran perfectly.
God bless you!
Thanks again
Sushant said on September 20, 2011
Hey was trying to run the class file from cmd after a long years and had stuck with this beginners time error. But suggestion of including classpath of the .class file using set classpath = and then running java command worked really well.
Thanks a ton !!!
nash said on September 28, 2011
@Suntro2007: u saved me man . I tried all other solutions but u r solution only worked . finally before leaving home i Just tried ur solution for a last try. For my surprise it worked. THNXman
@all :thnx
Nivedha said on October 13, 2011
hai i need to know how the mapping between swing and servlet happening
orbanbalage said on October 21, 2011
@Luis Adrián Ferreyra said on March 2, 2011
WOW man, so simple, but really I had to struggle through all things to find your final comment. thx bro :)
nagaraj said on November 4, 2011
hi am using jdk 1.4, wheni try to build the program using ANT it shows error like Exception in thread “main” java.lang.NoClassDefFoundError
please help me out !
sivasankar said on November 24, 2011
hi every one…
when i try to run Hibernate annotation basic program it show this error
please help me………….
Exception in thread “main” java.lang.Error: Unresolved compilation problem:
at edu.test.Example.main(Example.java:17)