Java: Exception in thread main java.lang.NoClassDefFoundError
Posted by David Kirk in Java programming
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.
About David Kirk
View more articles by David Kirk
The Conversation
Follow the reactions below and share your own thoughts.





October 12, 2008 at 10:41 pm, LP said:
Very helpful! I was stuck on this.. Thanks
October 14, 2008 at 9:26 pm, Mimi said:
My Classpath looks right, but I still get the error: Exception in thread “main”
.;C:Program FilesJavajdk1.6.0_01lib
November 14, 2008 at 12:42 pm, Rajesh said:
the classpath should include the directory in which u r keeping ur own class files.
February 04, 2011 at 12:30 pm, Sumsin123 said:
by default CLASSPATH is always current directory. Setting up CLASSPATH variable explicetely overrides this value
February 28, 2011 at 6:08 am, Deathdragon6 said:
no lib C:Program filesjavajdk1.6.xxxxxbin
March 25, 2011 at 10:01 am, C Bala86 said:
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
March 25, 2011 at 10:02 am, C Bala86 said:
Sorry class file was not getting generated previously
October 22, 2008 at 3:35 am, Andy said:
I’m sorry it did not work.
December 18, 2008 at 5:33 pm, chandu said:
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=….
February 12, 2009 at 11:10 am, Amruta said:
Thank you!! It really helped me.
i just copied my files in bin dir. try doing this.
February 25, 2009 at 10:43 am, harpreet said:
thank you it really helped me
March 21, 2010 at 11:54 am, Pranav said:
yp it helped me too
March 29, 2010 at 3:03 pm, Anonymous said:
Hey chandu thanks a lot it worked out for my final yr project thanks a lot once again
October 22, 2008 at 10:29 pm, CP said:
I have the same issue Exception in thread “main” java.lang.NoClassDefFoundError: any luck
October 23, 2008 at 2:16 pm, v said:
Just call this at the directory where you classfile XYZ.class is located :
java -classpath . XYZ
November 11, 2008 at 6:58 am, karep said:
salam
didn’t work for me …
any idea ?? :’(
wassalam
November 13, 2008 at 11:04 pm, Nick said:
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
June 28, 2010 at 1:29 pm, Somedude said:
Thanks Nick, I feel silly….
October 04, 2010 at 9:21 pm, husy said:
hmm
March 15, 2011 at 10:14 am, Rajroy 002 said:
sep path
March 31, 2011 at 3:34 am, Popujari said:
setting path till again give same error no class deffound
February 08, 2010 at 6:52 am, Anonymous said:
hey bro’s thnx it solved my issue
February 12, 2011 at 1:49 pm, Nk3527 said:
i have found error “Exception in thread “main” java.lang.NoClassDefFoundError” when i was tring to execute my own packages.What is solution
November 15, 2008 at 10:24 am, springrider said:
Thanks a lot! It help me!
February 03, 2009 at 6:31 pm, abhishek said:
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
November 15, 2008 at 1:09 pm, Tzell said:
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?
December 12, 2008 at 7:44 am, FrederikNS said:
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.
February 04, 2010 at 6:57 am, asif said:
Yes it worked in eclipse!! thanks.
February 08, 2009 at 6:13 pm, stacy said:
try netbeans
December 07, 2008 at 8:31 am, ahmad aghajani said:
My Classpath looks right, but I still get the error: Exception in thread “main”
.;C:Program FilesJavajdk1.5.0_01lib
December 17, 2008 at 2:04 pm, Jim Thomas said:
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.
December 18, 2008 at 5:43 pm, chandu said:
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……
December 30, 2008 at 3:05 pm, grace said:
you say executing your program using … pls how exactly do i execute it. i need the basic steps
January 06, 2009 at 7:38 am, Sushil Karane said:
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)
January 06, 2009 at 9:00 pm, JAaronAnderson.com said:
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
January 11, 2009 at 11:56 am, Abhhilash said:
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
January 16, 2009 at 9:01 pm, irene said:
noooooo…. i have tried it all….
it keeps saying that java.lang.noclassdeffounderror thing…
January 23, 2009 at 8:09 pm, Nathiya S said:
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
January 28, 2009 at 5:43 pm, Martin said:
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
January 27, 2009 at 8:01 am, Rakesh said:
Thanks great info
February 06, 2009 at 6:09 am, bothanks said:
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!!
February 12, 2009 at 11:18 am, Amruta said:
if After setting the path also it doesnt work.. save all files in bin dir and run the prgram using that path.
February 16, 2009 at 10:33 pm, Neicey said:
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
October 14, 2009 at 9:29 am, Anonymous said:
is it a problem of program?.
February 17, 2009 at 5:41 am, Sham said:
Thanx a lot very usefull!!
February 23, 2009 at 9:37 pm, sad said:
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
March 12, 2009 at 9:07 am, techno said:
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…
March 24, 2009 at 8:00 am, desperado said:
thanks techno, great advice!
July 03, 2009 at 10:55 pm, Su said:
Your advice point out what I missed. Thz alot techno.
February 26, 2009 at 5:38 am, The One said:
Ha! I figured it out! I just wasn’t compiling every file! “javac *.java” fixed it all! YES!!
April 30, 2009 at 10:13 pm, Anonymous said:
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….
February 26, 2009 at 7:22 pm, Gary Lesperance said:
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”.
March 10, 2009 at 11:54 pm, GXOne said:
OMG Thankyou After 5 Hours Thankyou.. with that advice it all works exactly the way it should LOL
February 27, 2009 at 6:55 pm, nice said:
hi to all
too , i have error :
Exception in thread “main” java.lang.NoClassDefFoundError: nameclass
help me.
March 10, 2009 at 8:50 am, Crimson said:
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.
November 16, 2009 at 11:11 am, neusbloed said:
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.
February 19, 2010 at 3:23 am, iedoc said:
WOW! finally! that was it, just don’t put the extension on it! damn, thank you!
August 05, 2010 at 3:40 pm, Nehadhmn said:
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!!
October 13, 2010 at 1:40 am, Awoo100 said:
What a deuchebag why didnt I think of this!
March 24, 2009 at 7:53 am, desperado said:
i used textpad and i still got the same error, can anyone tell me what’s wrong?
March 31, 2009 at 12:48 am, Thomaso said:
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
June 24, 2010 at 2:02 pm, Pandian said:
thank u very very much…. the spaces helped me a lot….
December 11, 2010 at 12:03 am, Vin said:
Thanks Thomaso.. it worked.. !!
April 06, 2009 at 12:22 pm, jango19 said:
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..
May 14, 2009 at 11:34 am, Ram said:
Hi ,
First set the JAVA_HOME variable with your bin directory.
then try to run .it will help u.
Regards
Ram Yadav
April 06, 2009 at 1:59 pm, Anonymous said:
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
April 17, 2009 at 4:48 pm, aravind said:
thanq very much for giving the solution…….
April 29, 2009 at 11:54 am, nabil said:
Awesome.
It worked great
May 19, 2009 at 2:00 am, hello said:
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?
May 19, 2009 at 2:05 am, hello said:
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
May 19, 2009 at 2:06 am, hello said:
and instead of joader its loader sorry for that
May 25, 2009 at 2:38 am, Kieran Taylor said:
!!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.
May 25, 2009 at 3:39 am, Loser said:
Worked for me !!!
May 25, 2009 at 9:12 am, sixlead said:
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
June 17, 2009 at 12:25 pm, Anonymous said:
Does not work
June 19, 2009 at 10:02 am, Ian said:
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
June 23, 2010 at 1:39 pm, Michael said:
THIS THIS THIS, finally. I’ve been trying to fix this for a while and this was exactly the solution I needed.
July 04, 2009 at 6:29 pm, rahul agarwal said:
thanks for the replies that have been posted….
i am so glad that my problem has been solved…
July 21, 2009 at 7:55 pm, Name said:
THANK YOU! My God this problem was so annoying
July 23, 2009 at 11:06 am, Anonymous said:
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
July 25, 2009 at 3:45 pm, vazeer said:
Thank You it really worked for me
July 27, 2009 at 8:20 pm, Anonymous said:
That worked! Thanks a lot,
It would probably help if you explicity indicate that the extension “.class” should not be used when using “-classpath” .
July 27, 2009 at 8:21 pm, Anonymous said:
Ops, should’ve read the above comments first!
my bad.. lol
July 30, 2009 at 3:01 am, Anonymous said:
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.
August 06, 2009 at 7:23 am, Anonymous said:
for coming out from this type of error
we can run the programm by using diffrn style..
like
java -cp . className
August 07, 2009 at 6:58 pm, Anonymous said:
It might be due to packages.
Try removing any “package” from the top of your *.java files.
August 13, 2010 at 7:28 pm, naveen said:
thanks a lot abdul, i have been trying to solve this problem for 7 hrs !
finally i got the solution
November 05, 2010 at 3:59 am, Priyadarshini said:
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.
August 13, 2009 at 3:32 pm, Anonymous said:
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
August 23, 2009 at 1:54 pm, Anonymous said:
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>
August 14, 2009 at 9:23 pm, Anonymous said:
this happening 2 me, now i cant play a runescape private server thats 508, help me please?
August 16, 2009 at 9:47 am, b00red said:
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?
August 17, 2009 at 2:22 am, Hamhama said:
For a beginner you may get this error also if you run:
java helloworld.class
Instead try to run:
java helloworld
August 19, 2009 at 10:45 am, Anonymous said:
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.
August 26, 2009 at 1:48 am, Anonymous said:
No, java -classpath . helloworld did not work. What next?
August 27, 2009 at 3:40 am, Anonymous said:
Thanks, It helped
August 27, 2009 at 7:30 am, Ankzz said:
It works.. One needs to pay heed to what has been said… Follow it step wise and U wont get any error
September 11, 2009 at 9:15 am, Anonymous said:
superb information. excellent !
September 16, 2009 at 11:24 am, Anonymous said:
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
September 21, 2009 at 6:48 pm, Anonymous said:
thnx…great work buddy.It solved the problem for me.thanks a lot.
September 22, 2009 at 12:26 pm, Anonymous said:
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
September 27, 2009 at 7:20 pm, Kevin said:
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.
October 27, 2009 at 5:40 am, Anonymous said:
how do you execute it with THAT command? like what do you do? where do you type that in (java -classpath)?
October 28, 2009 at 12:11 pm, Anonymous said:
Ya, I’ve read all of these comments and have no clue where to type the java -classpath . XYZ
November 04, 2009 at 5:27 am, Anonymous said:
Thanks … this works for me… I have been seem this type before but I was typeing ‘.’ close to ‘-classpath’ …
November 06, 2009 at 7:14 am, Anonymous said:
thanks a lot it was really heplful..
November 13, 2009 at 2:30 pm, Alan said:
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 !
November 18, 2009 at 6:40 am, Anonymous said:
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
November 27, 2009 at 4:50 pm, Setare said:
thank you for your help in solving this java error.
December 03, 2009 at 2:55 pm, Anonymous said:
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.
December 17, 2009 at 5:04 pm, Anonymous said:
Thanks! this was helpful for me to resolve a pestering issue!
January 05, 2010 at 3:17 pm, kiran said:
while intepreting a program in java dont put .java after class name otherwise u will get (thread “main” java.lang.NoClassDefFoundError:)
January 13, 2010 at 6:30 am, Anonymous said:
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)
January 13, 2010 at 6:31 am, Anonymous said:
pls pls help me
January 16, 2010 at 9:14 am, Chitre Mangesh said:
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
February 28, 2011 at 8:42 pm, Anonymous said:
Thanx ……….this worked !!!!!!!!
January 24, 2010 at 12:11 am, Banananana said:
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.
February 08, 2010 at 4:28 pm, Anonymous said:
im getting the error java.lang.NoClassDefFoundError:
my classpath is c:jdk1.5lib.
give me a help pls
February 15, 2010 at 12:40 am, joe said:
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???
February 15, 2010 at 12:41 am, joe said:
haveing=having and scape=same (sry typos)
February 16, 2010 at 5:37 pm, Anonymous said:
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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
February 17, 2010 at 6:59 pm, Anonymous said:
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
March 05, 2010 at 9:31 am, Anonymous said:
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
March 05, 2010 at 9:37 am, Anonymous said:
the problem was i didnt put space
D:java -cp E: *hello
the * is the space i forgot
This may help other
March 09, 2010 at 6:30 am, Nitin said:
Thanks.. was helpful..
March 10, 2010 at 6:13 am, Al said:
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!
July 27, 2010 at 7:35 pm, Aa said:
Thanks Al !! This is what I looked for!!!
March 10, 2010 at 4:14 pm, Anonymous said:
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
March 11, 2010 at 3:44 pm, Anonymous said:
Thank u so much . Your idea helped me a lot .
March 12, 2010 at 4:39 pm, Anonymous said:
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.
July 25, 2010 at 6:21 pm, Mahrizal said:
thanks , it usefull for me
thanks a lot
April 05, 2010 at 1:27 pm, Marin van Zandvoort said:
Many thanks!
I almost give up, but then I found your short-and-really-to-the-point answer to the problem.
April 14, 2010 at 6:06 am, Anonymous said:
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.
April 21, 2010 at 12:40 pm, Anonymous said:
the
April 21, 2010 at 12:41 pm, Anonymous said:
thing
April 23, 2010 at 8:51 pm, Anonymous said:
alert(‘hi’)
April 23, 2010 at 8:53 pm, Anonymous said:
good
April 23, 2010 at 8:55 pm, Anonymous said:
nice
April 24, 2010 at 1:28 pm, Anonymous said:
there is a exception error in swing
April 29, 2010 at 11:07 pm, Anonymous said:
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
April 29, 2010 at 11:13 pm, Anonymous said:
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
April 30, 2010 at 5:16 pm, Anonymous said:
if you have defined a classpath then go to that location and execute the pgm, else you should not be having problems
May 02, 2010 at 10:56 pm, Anonymous said:
What does that mean?
May 16, 2010 at 5:08 am, Anonymous said:
thank you!!
May 21, 2010 at 6:39 pm, Dhiroj said:
many many thanx
really a helpful data
May 26, 2010 at 3:02 pm, Anil said:
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.
June 16, 2010 at 10:58 am, Jenefar Esther04 said:
its very useful to me.thanks
June 23, 2010 at 5:15 am, Renuka salavi said:
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)
June 30, 2010 at 5:34 am, HugeIdea said:
You should miss the .; in front of your classpath. add those to your classpath, and it should work fine.
June 28, 2010 at 12:53 am, Fr said:
Man.. Thanks ! I was stuck on this for like 2 hours
July 02, 2010 at 12:39 pm, Ollan_misa said:
wath path i can use in window 7???? tnx im stuck doing my home work :/
July 09, 2010 at 6:42 am, Ds said:
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.
November 16, 2010 at 8:04 am, Catony said:
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.
July 15, 2010 at 5:15 am, Svsreddy01 said:
Exception in thread “main” java.lang.NoClassDefFoundError
this error will occur wat i do plese give me answer
July 30, 2010 at 3:27 pm, Live_long6 said:
My class path is proper….even i am getting .class file…but it show me java.lang.noclassdeffounderror error plz help me thxs..
July 30, 2010 at 7:55 pm, Suntro2007 said:
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.
March 07, 2011 at 11:21 am, TomDh said:
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
August 02, 2010 at 5:37 pm, Reeteshdas said:
the above solution does not solve the problem.
August 27, 2010 at 3:18 am, Shg23 said:
I solved that callin my program without .class extention
August 13, 2010 at 2:29 pm, Conor said:
Holy crap! Worked like a charm!
August 28, 2010 at 5:23 am, Nvenkat Ede said:
what is the permanent sol for java.lang.NoClassDefFoundError Exception without writing -classpath explicitly when ever we have to run the .class file
September 11, 2010 at 7:36 am, Girish0204 said:
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?
September 15, 2010 at 7:30 am, Anonymous said:
Helped me a lot
September 20, 2010 at 6:07 pm, Venkatesh Marni said:
set classpath=.; in command prompt
September 22, 2010 at 10:30 pm, Fredd said:
Debes de asegurarte que el .class se este guardando en el directorio actua
September 23, 2010 at 12:26 am, Silver_manta said:
Thanks so much!!!!
October 06, 2010 at 6:54 pm, Veb_405 said:
thank u very much to solve my problem
November 13, 2010 at 5:26 am, Lindsay said:
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.
November 14, 2010 at 2:39 am, Mail2yugi said:
thanks its working
November 15, 2010 at 4:13 pm, Sarav Preet Singh said:
very very thanx
November 19, 2010 at 10:14 am, vineet said:
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
November 25, 2010 at 3:39 am, Amit said:
it’s really helpfull..
Thanx
November 25, 2010 at 2:39 pm, Utkarsh said:
not working yet
December 01, 2010 at 9:42 pm, Amara said:
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!!
December 02, 2010 at 8:29 pm, Amara said:
I got it resolved when i used
C:Documents and SettingsxxxxDesktopJava Files New>java org.jinterop.dcom.test.MSWord
December 31, 2010 at 12:59 am, ANIMEMANIX said:
were do i write that,
im making a rs server
wat is a classpath? lol
December 08, 2010 at 2:03 am, Rahmadhany T said:
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.
December 12, 2010 at 1:02 pm, Sowmya said:
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
January 01, 2011 at 5:39 am, Duckiesgrandpa said:
I just learned that Capitalization is also important. If your class file is named HelloWorld then helloworld won’t work.
January 01, 2011 at 10:07 pm, Chap said:
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 . . .
January 25, 2011 at 4:00 am, Manish said:
Hi guyz I am looking for a program which print everytime on pressing enter Hello using the thread in Java
January 25, 2011 at 4:01 am, Manish said:
can anyone tell me how we can write a program to open an internet explorer in Java
January 25, 2011 at 8:15 pm, who885 said:
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
February 17, 2011 at 11:38 pm, srileo said:
set environmental variables first…
February 24, 2011 at 7:55 am, Raymond said:
Sorry, i also face this problem.
I not really know bout java.
What mean of set environmental variables?
got example?
February 03, 2011 at 11:28 am, P4_pacific007 said:
when I compile a simple prog it points error towards the dot between
system.out as in system.out.printin()
February 22, 2011 at 5:06 am, Chitra_12 said:
its System.out.println()
first character ‘s’ should be in uppercase
February 13, 2011 at 6:42 pm, ravi kiran naidu said:
it’s working i liked it
February 22, 2011 at 5:01 am, Chitra_12 said:
When im executing the simple java program ..
i get
Exception in thread “main” java.lang.NoClassDefFoundError: classname.
February 22, 2011 at 5:03 am, Chitra_12 said:
what commands should give now if help me
February 24, 2011 at 10:46 am, alien said:
this is great. thank you very much.
my problem was the missing ./ in CLASSPATH
March 01, 2011 at 6:56 am, L_savitha said:
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
March 02, 2011 at 2:30 pm, Luis Adrián Ferreyra said:
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.
March 06, 2011 at 6:24 pm, Chiragpatel said:
just put .; in ur class path and it ll work
this is message from GOD
March 06, 2011 at 6:25 pm, Chiragpatel said:
.: period semicolon
March 07, 2011 at 4:14 pm, Imran Sharif said:
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 ???
March 09, 2011 at 1:47 pm, Magnus said:
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”
March 11, 2011 at 5:02 pm, Onkdurga said:
It is very nice…gives the solution exactly
March 15, 2011 at 3:53 am, vinay singh said:
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………
March 15, 2011 at 3:55 am, awsmvini said:
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………
March 19, 2011 at 10:20 pm, Rybka2323 said:
omg… nothing work ;( what i need to do!? HELP!!!!!
March 25, 2011 at 7:57 pm, Jagadish_t said:
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.
March 30, 2011 at 1:31 am, dhruv said:
thank u sir thank u , u saved my receding hairline
May 13, 2011 at 6:55 am, Pam said:
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?
May 22, 2011 at 11:12 am, M Bhagyabhushan said:
frustated wit this problem and got solution
May 29, 2011 at 9:29 am, Kaucuk said:
Watch out the case sensitivity like class hello, file hello etc
June 20, 2011 at 4:09 pm, yeyeye said:
waw, thanks very much! You are really helpful! Your recipe is delicious! LOL
July 17, 2011 at 4:33 am, JP@ classpath in Java said:
nice recipe. I also found this link quite useful
3 ways to resolve NoClassDefFoundError in Java
July 17, 2011 at 4:33 am, JP@ classpath in Java said:
nice recipe. I also found this link quite useful
3 ways to resolve NoClassDefFoundError in Java
July 22, 2011 at 11:43 pm, Shawna said:
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.
August 21, 2011 at 8:39 am, madu said:
how to get only two precision after decimal in java..eg.3.8989E-34,MUST BE MADE TO 3.89
August 23, 2011 at 8:39 am, Anthony said:
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
September 20, 2011 at 8:39 am, Sushant said:
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 !!!
September 28, 2011 at 4:48 am, nash said:
@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
October 13, 2011 at 4:40 pm, Nivedha said:
hai i need to know how the mapping between swing and servlet happening
October 21, 2011 at 7:44 am, orbanbalage said:
@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
November 04, 2011 at 3:24 am, nagaraj said:
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 !
November 24, 2011 at 2:38 am, sivasankar said:
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)
February 11, 2012 at 3:04 pm, C Mihai said:
Use this simple command before running the FileName.class in cmd :
set classpath=%classpath%;.;
this is all
March 10, 2012 at 5:46 am, Ravi Bhosle said:
Its really helpfull……………
but i don’t know why it gives error even though when i have set the classpath correctly.
March 14, 2012 at 11:12 am, jayashree said:
Exception in thread “main” java.lang.NoClassDefFoundError: nameclass
this error is being came in my project plz help me