Create an account | Log in | Password | Contact Contact us



Get ExtraWatch PRO:

Special discount
9,99 EUR lifetime license
Money back guarantee

Extension directory rating:
rating 4.86 rating 4.86 rating 4.86 rating 4.86 rating 4.86
4.86

Download

ExtraWatch is web analytics website visitor tracking tool. Learn more...

Features: Click heatmap, conversion tracking, interactive HTML5 traffic flow chart and many other useful functionalities, which will help you to optimize your site.



Login:

About CodeGravity.com:
Freelance profiles Freelance
Open freelance projects Projects
Joomla and JoomlaWatch forum Forum
Best programming websites Resources
Best programming websites  Site map
 

Exception in thread "main" java.lang.NoClassDefFoundError


A friend of mine wanted to start to learn java, and I wanted to help him, so we created a simple Hello World example.

public class Hello {

public static void main(String argv[]) {

System.out.println("Hello world !");

}

}

then, when you compile it:

> javac Hello.java

and want to execute it:

> java Hello

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

We set the CLASSPATH and JAVA_HOME enviroment variable correctly, and the problem was still the same..

When we copied the Hello.class into a lib directory of JAVA_HOME, it worked, but not from the current directory !

We tried different versions of java.. and do you know where this stupid problem is?

in the CLASSPATH there should be:
CLASSPATH=.;c:\programme\jboss\lib;c:\programme\
j2sdk1.4.2_08\lib;c:\programme\j2sdk1.4.2_08\jre\lib; ...

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 :)




 

Problem:
Basically, the Exception in thread "main" java.lang.NoClassDefFoundError:

means, that the class which you are trying to run was not found in the classpath.

Solution: you need to add the class or .jar file which contains this class into the java classpath. When you are running a java class from the command line, you need to add the dot (.)

java YourSingleClass -cp . 

into the classpath which tells the JVM to search for classes in actual directory.


If you are running a class from a .jar file, you need to add this jar file into the classpath:

java org.somepackage.SomeClass -cp myJarWithSomeClass.jar



 

Comments  

 
+7 #1 bhavin 2010-07-01 13:13
I tried setting in the PATH, CLASSPATH, JAVA_HOME, from going into the Environment variables, but it didnt worked.

But then later i tried this....
set classpath=%classpath%;.;
by going into the folder where my java code is there, and it worked.

Thanks a lot rishi :)
Quote
 
 
-2 #2 preeti 2010-07-08 21:18
m still not able to get it
plz help
:cry:
Quote
 
 
-1 #3 preeti 2010-07-08 22:04
hey it really helped me
thank u all guys
Quote
 
 
0 #4 sangeetha 2010-07-15 19:25
Quoting rishi:
in command promt go to ur folder whr ur java file exist and write this
set classpath=%classpath%;.;

best of luck for java programming.

thank you soo much rishi it was really helpful.....
Quote
 
 
0 #5 manisha 2010-07-17 16:25
how to set classpath and java_home plz give me reply
my jdk1.6 installed different folder then my java program
folder
Quote
 
 
+1 #6 amarjit 2010-07-19 18:08
i have not understood this lang exception.kindly explain it by displaying on user screen ,command by command.i hope u got it.waiting for ur reply eagrly.
Quote
 
 
-1 #7 shyamendra 2010-07-21 12:23
Classpath
.;c:\j2sdk1.4.2_04\jre\lib;./;z:\classes

JAVA_HOME
c:\j2sdk1.4.2_04

PATH
.;c:\j2sdk1.4.2_04\bin;

CATALINA_HOME
c:\Tomcat
path will according you java installtion
Quote
 
 
-1 #8 NaviNice 2010-07-23 07:12
Cool Dude.
Nothing Happen strange...
just go to system environment and remove all path variable which include java path.....
now again create a new path variable and paste there java bin path...
which is usual C:\Program Files\Java\jdk1.6.0_19\bin :lol:
Now It will Work ..........
The problem behind this error is that there are multiple java path variable in system environment variable . . .
Or
you have different version of jdk or jre
Quote
 
 
+4 #9 NaviNice 2010-07-23 07:31
:lol: Cool Dude
Nothing happen strange.
you just right click on "my compute"r icon on desktop.
Go to "properties".
Then Go to "Advanced".
Then go to "environment variables"
where the java path is set in path or may be classpath or JAVA_HOME ..
Delete all java path..
Now again take a new path variable and set java path in it which is mostly C:\Program Files\Java\jdk1.6.0_19\bin
then save it. . . . . . . .

Now What is the problem behind this error..
1. multiple path variables with java path
2. you have different JRE and JDK version



Njy
Quote
 
 
+2 #10 Swamy 2010-07-26 02:48
Hi

I am a newbie. I too faced the same problem. It worked fine in the command prompt as I have set the class path right. But , in Eclipse if i give the class name as hello.java or hello.class i got the error. When i tried using hello it worked like magic. I understood now. :-)
Quote
 
 
-3 #11 Mani Prakash 2010-07-27 11:50
Thanks a lot. it works
Quote
 
 
-1 #12 Kanchan 2010-07-29 07:25
Thank You Very Much. I was trying to resolve this problem but didn.t succed.
ur solution helps me lot. :lol: , :D :D
Quote
 
 
-2 #13 K@rtik 2010-07-29 20:23
actually when u install java u only require to set its path
, u rally not need to set its CLASSPATH and JAVA_HOME variable because by setting path to its jdk's bin direcotry it automaiticlly treat and compile and run from any folder or directory
Quote
 
 
+1 #14 Satyadeep 2010-08-07 19:50
:-) Thank you very much
That had made my day
Quote
 
 
-2 #15 unknownq 2010-08-12 12:34
Quoting Deepak:
It was really helpful. Thanks a lot. 8)
really worked
Quote
 
 
-4 #16 Neeraj 2010-08-27 10:39
Thanks a lot..it really worked..
Quote
 
 
-4 #17 Mitul_Patel 2010-09-01 05:59
Thanks man great help
Quote
 
 
-3 #18 Avinash Bikumalla 2010-09-03 03:14
Thanks for the solution :-) :-)
Quote
 
 
+2 #19 JayB 2010-09-09 18:41
Hey I found this interesting. All of this didn't help me, but I had the same error. The problem for me was that I was using an external IDE and had missed a package declaration at the top of the page. I remove it and viola! XD
Quote
 
 
+4 #20 C12Simone 2010-09-13 14:35
CLASSPATH
C:\Program Files\Java\jre6 \lib\ext\QTJava .zip;

Add a semi-colon(;) at the end of the classpath.
This really Works for me for java 6.
Quote
 
 
+2 #21 Cem Arslan 2010-09-15 00:15
(1) javac HelloWorld.java
(2) java HelloWorld

java helloworld ---> will not work you have write same class name... if it is HelloWorld write like that if it is HeLLoWORLD write like that
Quote
 
 
-1 #22 Sasmita 2010-10-10 03:46
thanks... a lot :lol: :D :roll:
Quote
 
 
-1 #23 Praddy 2010-10-11 17:47
Helped a lot! thank you! 8)
Quote
 
 
-2 #24 udita 2010-10-14 15:16
ohh ..thnk u soo mucchh .. it was of great help.
Quote
 
 
+1 #25 udita 2010-10-14 15:17
thnxx gr8 help .. :)
Quote
 
 
0 #26 Vani 2010-10-18 08:05
install jdk then go to my computer properties advance option their select environment select new set jdk bin directory path click ok....

in command prompt go to ur folder whr ur java file exist and write this
set classpath=%classpath%;.;

surely it works try this....All the best...
Quote
 
 
+2 #27 Snail 2010-10-20 14:50
Do you know where my stupid problem is?
I put a ',' instead of ';' after '.' in the CLASSPATH :-*
Quote
 
 
+2 #28 sandysam 2010-10-20 16:08
THANKS A LOT!!!!
It was very helpfull!!!!! :D :lol:
Quote
 
 
+2 #29 neera singh 2010-12-23 06:12
thanks a ton :lol:
Quote
 
 
+1 #30 neera singh 2010-12-23 07:26
thanks a ton it worked.......... :lol:
Quote
 
 
0 #31 Shaahid 2011-01-02 20:22
Thanks a lot for the info. Its working
Quote
 
 
0 #32 Sadiksha 2011-01-04 07:01
Thanks a lot, it really worked..... :lol: :-) :D
Quote
 
 
0 #33 Neeraj soni 2011-01-19 06:56
if u get a solution for the above problem u faced, pls provide for me also since i too facing the same
Quote
 
 
-2 #34 Preeti 2011-01-25 09:56
Really helpful.Thanks :)
Quote
 
 
+1 #35 Javin@ TibcoTutorial 2011-01-29 09:37
Hi,

Its worth noting that if you have two classes with same name in classpath in that case one which comes earlier in classpath will get picked up. this concept is very useful to test patch releases where you update only few classes to quickly test patch release or have added some debug print statement to troubleshoot any issue. to read more about How classpath works in Java

Thanks
Javin
Why String is immutable in Java
Quote
 
 
+1 #36 landun 2011-02-13 21:02
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"
Quote
 
 
-1 #37 vinothtel 2011-02-25 06:04
I connect java with mysql...
At run time exception thread:no classdef found exception: filename
error will be displayed....
Quote
 
 
0 #38 romasius 2011-03-14 13:54
Can someone explain why Java guys did so (-cp .):
java YourSingleClass -cp .
It will be bether that Java will search automatically for classes in actual directory-directory from which is running application:
java YourSingleClass
Quote
 
 
0 #39 iamshoaib@gmail.com 2011-04-15 15:00
Thanks man it works for me, I was also forgot to give that dot even I am not new to java, Really helpful note, 10Q
Quote
 
 
+2 #40 thedrs 2011-04-27 09:40
Common mistake that leads to the above error (even when all paths are correct) is doing:

java Hello.class

instead of actually doing the correct:

java Hello
Quote
 
 
0 #41 sanarafaai 2011-04-28 10:38
thnkuuuuuuuu sooooooooo much...it really worked....GOD BLESS U....:) JAZAAK ALLAH
Quote
 
 
0 #42 jusC 2011-05-02 08:30
it worked for me too

cool
Quote
 
 
0 #43 venkatavarma 2011-05-10 12:14
Quoting rishi:
in command promt go to ur folder whr ur java file exist and write this
set classpath=%classpath%;.;

best of luck for java programming.


rishi thankqqqqqqqqqq qqq alot
u solved my problem
Quote
 
 
0 #44 venkatavarma 2011-05-10 12:39
Quoting shyamendra:
Classpath
.;c:\j2sdk1.4.2_04\jre\lib;./;z:\classes

JAVA_HOME
c:\j2sdk1.4.2_04

PATH
.;c:\j2sdk1.4.2_04\bin;

CATALINA_HOME
c:\Tomcat
path will according you java installtion

Quoting shyamendra:
Classpath
.;c:\j2sdk1.4.2_04\jre\lib;./;z:\classes

JAVA_HOME
c:\j2sdk1.4.2_04

PATH
.;c:\j2sdk1.4.2_04\bin;

CATALINA_HOME
c:\Tomcat
path will according you java installtion



"shyamendra"

thankqqqqqqqqqq qqqqqqqqqqqqqqq
a lot u solved my problem
god skills u have keep it up
i
Quote
 
 
0 #45 Ankurp 2011-05-14 10:37
Thanks a ton dude....
U r the man.....
This thing was trying to live rent free in my head.
Quote
 
 
+2 #46 ashwanisi 2011-06-07 22:11
Thanks Bro! you saved my life .
i am suffering from above problem from last week.

Really! a Single ' . ' Dot can change your life.
Quote
 
 
-1 #47 amaechi chizota 2011-06-12 08:15
please i like what's going on here. i am new to java and i kept having problems of noclassdeffound error in a particular program of mine. now this discussion here is a relief but i need to knwow how to set this classpath in windowsxp.
Quote
 
 
0 #48 Brandon G. 2011-06-14 21:31
I've recently started learning Java due to our website changing it's current location. While this solution may be elementary and already provided I have used it before.

If you are attempting to run the program using command prompt on Windows, try the following commands in command prompt:

cd signs >

java signs >


-- An example of the above would be --

cd C:\JavaClassFil es

java test


compile first!

This simple problem was being overlooked by myself and others that have attempted learning Java. The same error was shown due to the fact that the VM could not locate the .class file. Command Prompt will not load to your .class files directory unless you have specifically told it to target that directory on execution.

Again, this solution may be elementary and already posted; however, I was able to solve my issue by using it. I hope this helps someone and have a great day.
Quote
 
 
0 #49 Brandon G. 2011-06-14 22:29
Sorry about the "signs" thing above. I meant to post:

cd "the name of the directory that houses your .class file"
"ENTER"
java "the name of your .class file"
"ENTER"

This will change command prompts directory target from the current location to whatever you entered after "cd"

Sorry for the confusion and double post. I hope this post displays properly lol.
Quote
 
 
0 #50 CypherVirus 2011-06-16 00:52
It's Brandon G from earlier. I meant to say:

cd "the path to your class directory"
java "the name of your .class file WITHOUT using .class"

Hope this helps, sorry for the confusion.
I've tried posting this a few times but they failed. I hope this didn't become a triple or quadruple post XD
Quote
 
 
0 #51 soldier01 2011-06-16 08:41
Hola q tal, alguien me puede ayudar, al compilar con neatbeans me aroja un problema; me dice que la classe x.Main no tiene un metodo... quise hacer lo de la CLASS PATH pero no entiendo como
Quote
 
 
+2 #52 Nahuel 2011-06-18 16:16
I had the same error in Linux trying to run from the command line with
java myclass.class

Work fine doing:
java myclass
Quote
 
 
-4 #53 NoClassDefFoundError 2011-06-19 16:29
If you are getting java.lang.NoClassDefFound Error then must be there is a class which was present when you build the jar and successfully linked but not present while you trying to run the program, to fix this problem just check whether you are overriding classpath if not then just include that class into classpath By including that class into Classpath as suggested here
:D
Quote
 
 
0 #54 gauravmishra 2011-07-07 09:54
1.goto system properties.
2.in environment variable,search for classpath.
3.add ;.; in the end.
Quote
 
 
-1 #55 hmmm 2011-07-12 14:58
thank you very much
Quote
 
 
0 #56 MapleStrory 2011-07-17 15:44
I don't understnad it,
Can enyone please explan me how to fix:
exception in thread main java.lang.noclassdeffound error: net/world/worlds
So i can start World, Login Then Sercer.

Please....
TY
Quote
 
 
+1 #57 hooray 2011-07-18 15:33
thanks!! solved the error!!
Quote
 
 
+1 #58 Hareesh 2011-07-19 06:27
Quoting rishi:
in command promt go to ur folder whr ur java file exist and write this
set classpath=%classpath%;.;

best of luck for java programming.


Thanks rishi
Quote
 
 
+1 #59 Nagaraju.G 2011-07-26 17:50
Thank you, Thanks a lot Sir.
Actually i have worked many programs in java but i have not phases such a problem yet but now i am phasing now , you have given me clearance .once again thanks a lot.
Quote
 
 
+1 #60 swarupa 2011-08-04 10:00
D:\>java demo
Exception in thread "main" java.lang.NoClassDefFound Error: demo
Caused by: java.lang.ClassNotFoundEx ception: demo
at java.net.URLClassLoader$ 1.run(URLClassLoa der.java:202)
at java.security.AccessControlle r.doPrivileged(Na tive Method)
at java.net.URLClassLoader.findClass(URLCl assLoader.java:190)
at java.lang.ClassLoader.loadClass(Class Loader.java:307)
at sun.misc.Launcher$AppCla ssLoader.loadClass(Launc her.java:301)
at java.lang.ClassLoader.loadClass(Class Loader.java:248)
Could not find the main class: demo. Program will exit.
Quote
 
 
-1 #61 sudhirtekavade 2011-08-12 22:13
thanx .. i ws tryin 2 do it since 2 hours gettin same error..ur post really helped me.. thnk u so much
Quote
 
 
0 #62 Dhanush Dhanpal 2011-08-13 20:40
Hey guys the problem got solved....
was facing this issue even after having my paths set...

i reinstalled jdk many times...
but found out that the problem was with the classpath having another path also set other than jdk/bin.

i had tomcat installed so the path was set for that in classpath.

The class path before was:
C:\Program Files\Java\jdk1.6.0\bin;D:\SMES\j ava\tomcat\lib\ servlet-api.jar;

but when i reversed it to be:
D:\SMES\java\to mcat\lib\ servlet-api.jar;C:\Program Files\Java\jdk1.6.0\bin;

The problem got solved...
this problem dint exist before. but suddenly that happend,.
took me so long..
Quote
 
 
+1 #63 vignes 2011-08-15 07:34
your single line clear all my errors Thanks a lot RISHI
Quote
 
 
-1 #64 vignes 2011-08-15 07:35
your single line clears all my errors thankyou very much
Thanks RISHI
Quote
 
 
+6 #65 SAGAR DABAS 2011-08-31 04:46
If above all alternatives are not working than probably you have used "package something;" in your class,,, so to run this class get out of the current directory using "cd.." i.e. in the parent directory in which your "something" folder is. Thn use the full qualified name for running that class
like "java something.Myclass"
Quote
 
 
+1 #66 abcds 2011-09-07 06:22
here is another good article on how to resolve ClassnotFoundEx ception in java
Quote
 
 
+4 #67 ryalir 2011-09-08 15:06
Quoting KK:
set classpath=%classpath%;.;

it works thanks a lot

Thanks a lot yar
Quote
 
 
+1 #68 vibhu 2011-09-09 09:57
8) Thanks :)
Quote
 
 
-2 #69 kratnesh 2011-09-09 10:01
how to set classpath for jdbc application in fedora 15
Quote
 
 
0 #70 zqwer 2011-09-12 07:35
this is a symptom of why java is stupid.
Quote
 
 
0 #71 Avik Deb 2011-09-13 04:08
Thanks
Quote
 
 
0 #72 hammer_hit 2011-09-17 13:34
:lol:
this error comes due to usage of java classname.java
try using java classname
only
8)
Quote
 
 
0 #73 ZaidKazi 2011-09-19 19:18
hi i did used the java -classpath . thing and it worked very nicely

however now i used post #3 avesh's set path/classpath/java_home and now even the javac doesn't work :sad:
Please help i am using win7 and cannot revert the problem..
Quote
 
 
0 #74 ak 2011-09-29 20:10
This worked for me... found it on another forum

Executing your program using this command should correct the problem:
java -classpath . helloworld
Quote
 
 
0 #75 rohit 2011-10-04 13:32
i have used all the solutions given above in my class path but it is still giving tha same error guys
i m using jdk1.6.0_17 in windows 7


plss help me :sigh:
Quote
 
 
0 #76 taj 2011-10-05 14:34
Quoting sangeetha:
Quoting rishi:
in command promt go to ur folder whr ur java file exist and write this
set classpath=%classpath%;.;

best of luck for java programming.

thank you soo much rishi it was really helpful.....

What a Command line ...set classpath=%classpath%;.;

Great.... i got it .. works fine Thanks
Quote
 
 
+2 #77 pra$ad 2011-10-18 16:59
[quote name="Song Toan"]I'm a new guy to Java using JDK 6 in Windows. I stuck here few hours for this issue. None of the solutions found from Internet solved. Finally, I got it worked.

There are 2 ways:

1) Set CLASSPATH environment to C:/Program Files/Java/jdk1.6.0_11/jre/lib;./;
Your jdk installation may be at different location.

2) Use -cp option:
java -cp "C:/Program Files/Java/jdk1.6.0_11/jre/lib;./;"


it rally works.no doubt
Quote
 
 
+2 #78 SUNSHINE7565 2011-10-20 14:08
Please help! I am trying to transfer a program from my desktop to my Blackberry. Once I download it on my phone and try to run it I get the java.lang.noclassdeffound error. Any suggestions
Quote
 
 
0 #79 Aq.jakartha 2011-10-25 13:08
Thank u very much.
Very nice for your corporation.......... :lol:
Quote
 
 
0 #80 Manoj-sharp 2011-10-29 03:18
Hi its nice thank u very much......................
Quote
 
 
0 #81 ClassNotFoundExcepti 2011-11-08 11:49
Nice post. here is my way of solving NoClassDefFound Error in Java
Quote
 
 
0 #82 maddy007 2011-11-23 07:25
thank for the suggestion 8)
Quote
 
 
0 #83 jaya 2011-12-02 09:10
hi guyzzzz!
Actually Environment variable is a variable, which tells the os where to search for the given the commands. By default os can search files in c:\windows\syst em32.
We observe errors like javac is not recognized as internal or external command. To solve this problem we can set as PATH.
set PATH=where javac.exe file is installed.
set PATH= c:\programmfile \java\jdk 1.6-09\bin;.;
An Environmental variable can store multiple values, we can saparate it by using :(separator).
where as come to jvm, whenever we call the jvm in by default it search for current directory. That's y we specify th CLASSPATH
set CLASSPATH=where .class file is availble.
Quote
 
 
+1 #84 Someshwar 2011-12-15 06:15
It really helped, thanks a lot for the info.
Quote
 
 
+1 #85 A.Lepe 2011-12-16 02:22
Its incredible how this kind of situations can happen even having years developing in JAVA... I was trying to test some codes and it happened to me too! hehe
Thanks for posting it!
Quote
 
 
0 #86 Shiksha 2012-01-03 15:38
Hello,
I m getting this error pls resolve this---- :sad:
Exception in thread "main" java.lang.NoClassDefFound Error


Thnxs
Shiksha
Quote
 
 
+2 #87 PeDz 2012-01-23 03:48
public class Hello {

public static void main (String[] args) {

System.out.println("Hello World!");
}


}

i sttil get
java.lang.NoClassDefFound Error: Hello/java
Caused by: java.lang.ClassNotFoundEx ception: Hello.java
at java.net.URLClassLoader$ 1.run(URLClassLoa der.java:202)
at java.security.AccessControlle r.doPrivileged(Na tive Method)
at java.net.URLClassLoader.findClass(URLCl assLoader.java:190)
at java.lang.ClassLoader.loadClass(Class Loader.java:307)
at sun.misc.Launcher$AppCla ssLoader.loadClass(Launc her.java:301)
at java.lang.ClassLoader.loadClass(Class Loader.java:248)
Could not find the main class: Hello.java. Program will exit.
Exception in thread "main"
Process completed.



please help...
Quote
 
 
+1 #88 preeti 2012-01-23 12:18
thanks for the solution........my code worked!!!!!!!!! !!!thanks again
Quote
 
 
+1 #89 Ricardo_sv 2012-01-24 03:36
THANKS a lot : It Worked!!

We had been working around this error several days. It was amazing.
Quote
 
 
+1 #90 shiju 2012-02-04 06:25
thanks rishi thanks a lot.
Quote
 
 
+1 #91 radhaVIZB 2012-02-10 05:27
Thank you So much. This really helped me. I was very much worried but now I'm able to develop my programs efficiently.

Thanks a ton...
Quote
 
 
+1 #92 kandiwapa 2012-02-24 13:33
This only work when I am not include the package line is not in the code but if.. my if my code has
package simple.work;
public class Hello {

public static void main(String argv[]) {

System.out.println("Hello world !");

}

}

it does not work.. why?
Quote
 
 
+1 #93 jerrylyn 2012-02-25 07:01
thank you..now i'm able to see the output of my java programs..
i have no problem in doing my homework.. :-)
Quote
 
 
+1 #94 jerrylyn 2012-02-25 07:05
thank you so much...
Quote
 
 
+1 #95 jerrylyn 2012-02-25 07:06
it helped me a lot..i can now view the output of my java programs and no longer think of my homework.. :-)
Quote
 
 
0 #96 deepika 2012-03-03 13:47
i tried set classpath=%classpath%;.; but still iam getting noclassdeffound help me in resolving this
Quote
 
 
+1 #97 XAIN 2012-03-09 19:24
HELP HELP HELP.... PLEASE

THIS IS MY ERROR. WHEN I RUN MY FILE
java.lang.NoClassDefFound Error: rentalshop/Main
Caused by: java.lang.ClassNotFoundEx ception: rentalshop.Main
at java.net.URLClassLoader


Hey! is there any one who can solve my problem..... Plz heip me... i have tried and wrote set classpath=%classpath%;.; Many times but nothing happened.. Please Help me...
Quote
 
 
0 #98 ajith 2012-03-28 15:39
:lol: thank you guys :P
the solution set classpath=%classpath%;.; worked for me
:zzz
Quote
 
 
+1 #99 ajith 2012-03-28 15:42
thank you buddy :lol:
this solution set classpath=%classpath%;.; works for me : :P
Quote
 
 
0 #100 omoyibo 2012-03-31 18:03
Please help! I am trying to transfer a program from my desktop to my Blackberry. Once I download it on my phone and try to run it I get the java.lang.noclassdeffound error. Any suggestions
Quote
 
 
-1 #101 Toughs 2012-04-11 12:32
set classpath=%classpath%;.;
8) Worked!
Quote
 
 
-1 #102 LakshmiPriya 2012-04-16 19:35
Thanks so much.... That was great help!! :-)
Quote
 
 
+2 #103 EdinIT 2012-04-20 03:56
Thank you everyone. Even with all of your help and suggestions this took several hours. :-x

1st problem solved by #105 SAGAR DABAS :lol:
java helloWorld.helloWorld

2nd problem was trying from the wrong directories also solved by #105 SAGAR DABAS :lol:

3rd problem - did not use proper capitalization as command prompt doesn't care, but java does.
java helloworld.helloworld did not work solved by #72 Cem Arslan :lol:

I used the the set classpath=%classpath%;.; solution several times, but because of my other errors, I am not sure if it helped. :-?

I quit trying to pick up Java a couple times before because these basics are not covered even in the tutorials I have found. The authors assume you can figure it out, or they forgot how much trouble they had at first. How many people never get started because they can't get the tools configured? :sigh:
Quote
 
 
+1 #104 Nikita Khurana 2012-04-25 11:59
I am having this error while working with aglets Trying to run tahiti srever using java code. I made a batch file which contains all the commands used to run tahiti. Individually this batch file is running properly but when I try to run it using java code it gives an error which looks like "exception in thread 'main' NoClassDefFound Error com\ibm\awb\lau ncher\Main" Kindly resolve it as soon as possible.
Quote
 
 
0 #105 ichi 2012-05-02 02:36
:D soy feliz si funcionó
Primero puse:
set CLASSPATH =%CLASSPATH%;.;
luego corrí de nuevo
javac Hello.java
luego
java Hello
y se mostró en pantalla el texto"Hola Mundo"
Muy bien gracias!!
Quote
 
 
0 #106 ichi 2012-05-02 02:42
set CLASSPATH =% CLASSPATH%;.;
javac Hello.java
java Hello
thanks!! :lol:
Quote
 
 
0 #107 sanjay sj 2012-05-02 19:43
thanx :-)
Quote
 
 
0 #108 Roman D 2012-05-04 17:13
I am not sure where you guys took your example from but my Hello World example had this code in there that was causing the issue:

package jdg.ch04;
import java.lang.System;

class HelloWorldApp {
public static void main (String args[]) {
System.out.println("Hello World!");
}
}

As soon as I removed first two lines it started working just fine. So the correct example would look like this:

class HelloWorldApp {
public static void main (String args[]) {
System.out.println("Hello World!");
}
}
Quote
 
 
0 #109 surendra rawat 2012-05-16 08:07
hi...
how to set a path in linux....
pls help me..
Quote
 
 
+1 #110 op 2012-07-14 06:57
Quoting rishi:
in command promt go to ur folder whr ur java file exist and write this
set classpath=%classpath%;.;

best of luck for java programming.


it worked thanks ..OP
Quote
 
 
0 #111 priyak 2012-11-07 08:48
thanks! it resolved my problem!!!!
Quote
 
 
+1 #112 Vignesh Gautam 2012-12-15 21:57
Check this article! This should answer why so many people are into trouble.

http://www.jarticles.com/package/package_eng.html
Quote
 
 
+2 #113 harika 2013-01-23 07:03
I am new to java..when i am running javaclass from bat file i amgetting below eror ..

Exception in thread "main" java.lang.NoClassDefFound Error: Harikafinal (wrong na
me: harika/Harikafinal)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unk nown Source)
at java.security.SecureClassLoad er.defineClass(Unk nown Source)
at java.net.URLClassLoader.defineClass(Unk nown Source)
at java.net.URLClassLoader.access$100(Unknown Source)

at java.lang.ClassLoader.loadClass(Unkno wn Source)
at sun.misc.Launcher$AppCla ssLoader.loadClass(Unkno wn Source)
at java.lang.ClassLoader.loadClass(Unkno wn Source)
at sun.launcher.LauncherHelper.checkAndLoadMai n(Unknown Source)

Can anyone tell how to resolve it and what i have to put in classpath..with one example


Thanks in advance....
Quote
 
 
0 #114 raman9915 2013-01-24 17:06
thanks bro.. people like you, are really helpful for avoiding stupid problem.. thanx alot.. good work.. i was actually thinking for downloading the newer version just like you did.. thanx u saved my time.. :-)
Quote
 
 
0 #115 geethab 2013-03-02 07:10
i got a error like
exception in thread main java.lang.no class def found error caused by:java.lang.class not found exception
at java.net url class loader ..like something.....wat to do i dono....can anyone pls tell me a solution??????? :sad:
Quote
 
 
0 #116 justin jose 2013-04-10 07:21
the most easy and eficent command to avoid these type of error is
in command promt go to ur folder whr ur java file exist (C:-------/bin)and write this
set classpath=%classpath%;.;

then compile(javac filename.java)
then run(java filename)
Quote
 
 
0 #117 bjthom 2013-04-23 00:43
I'm Dumb, you just need to type:
set path=%path%;(location of javac.exe)

then it should work
Quote
 
 
0 #118 bjthom 2013-04-23 00:45
DON'T LISTEN TO ME! That solution seems to work.
Quote
 
 
0 #119 ravs 2013-07-20 08:37
I am new to java....when i compile a prog..i get the following error, i have installed the setup twice but same error:

Picked up JAVA_TOOL_OPTIO NS: -agentlib:jvmhoo k
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~1\HP\QUICKT~1\
bin\JAVA_S~1\classes;C:\PRO GRA~1\HP\QUICKT~1\bin\JAVA_S~1\classes\jasmin e.jar


PLEASE HELP!!.......
Quote
 
 
0 #120 ravs 2013-07-20 08:42
I am new to java..when i compile a program. i get following error,... PLEASE HELP

Picked up JAVA_TOOL_OPTIO NS: -agentlib:jvmhoo k
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~1\HP\QUICKT~1\
bin\JAVA_S~1\classes;C:\PRO GRA~1\HP\QUICKT~1\bin\JAVA_S~1\classes\jasmin e.jar
Quote
 
 
0 #121 matto 2013-10-30 11:59
Thanks for explaining this exception in thread "main" java.lang.noclassdeffound error

I was trying to find out what should be the problem regarding exception in thread "main" java.lang.noclassdeffound error and not I got it.
Quote
 
 
0 #122 Abhi86 2013-11-02 16:59
I found one another common reason. If you create the java file inside a package using IDE like eclipse, you will find the package name on the top of your java file like "package pkgName". If you try to run this file from command prompt, you will get the NoClassDefFound Error error. Remove the package name from the java file and use the commands in the command prompt. Wasted 3 hours for this. -- Abhi
Quote
 
 
0 #123 Neeraja 2013-12-06 10:42
same error for me i have set my class path also but its not working can u tell how to set class path
Quote
 
 
0 #124 Panel Beaters Westra 2013-12-16 14:02
your blog is very nice i like it
Quote
 
 
+1 #125 sowmya.k 2014-03-17 11:42
thanks abhi..... am also having same problem in java package.classpath is not worked then i removed package name....now its working...really its very helpfull thnks alot
Quote
 
 
0 #126 sudheerbabu 2014-05-27 15:03
Thank you very much. It helped me a lot.
Quote
 
 
0 #127 Mohit kuhar 2014-07-14 11:37
NoClassDefFound Error comes when the specified class was present during compilation but are missing at runtime. I had this problem as some class files were missing from classpath, when I added corresponding jar file then all errors were gone.

Below link may be useful

http://newtechnobuzzz.blogspot.in/2014/07/what-is-javalangclassnotfoundexception.html
Quote
 
 
0 #128 qqqqqqqqqqqqqqq 2014-08-12 10:00
i have installled java in C\program files...
but i wanna store ,,my programs in d drive in another folder..how to compile and rum these files from d drive..plz help anyone
Quote
 
 
0 #129 Does Text The 2014-08-13 17:46
Appreciate the recommendation. Let me try it out.
Quote
 
 
0 #130 Pree 2014-10-26 08:48
Quoting Anna:
Thanks a lot!!!!!!!!!!!! That was very helpfull.

whats so great helpful here?
Quote
 
 
0 #131 jikar 2014-10-28 08:19
I wanted to say those monkeys who developed JDK could not set it in a way that at the time of installation the other setting like path, pathclass etc also be set ?!!!!!
Quote
 

Add comment


Security code
Refresh


Recommended:
Codegravity.com featured at:

infochangeindia.org

kulevioilterminal.com

sunway.edu.my

northsidebaseball.com

admissions.au.edu

rincones.educarex.es

adlcweb.com

northdecoder.com

biblioteca.ase.ro

barnstablepatriot.com

Powered by Website Informer



We have now:
we have now pagerank 8 !




Partners:
Web analytics, Heatmap

Freelance ColdFusion, Flex, PHP

Obraz Bratislava

WinAsm Studio

Vyšné Ružbachy

Sochy, Reštaurovanie

R.E.M.



© Copyright 2003-2014 Codegravity.com - powered by ExtraWatch visitor tracking and heatmap tool