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

Introducing ExtraWatch live stats hosted in the cloud
- No need to install it as extension, just few lines of HTML code
- No impact on your server's performance
- Nightly email and SEO reports


Start monitoring within 3 minutes

Email:
URL:
See demo
Access your stats

After entering your email a HTML code will be sent to your email, which you need to include to your website. This is a 30-day trial of PRO version. All emails are private according to our privacy policy.




 


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  

 
+36 #1 Deepak 2008-01-31 13:51
It was really helpful. Thanks a lot. 8)
Quote
 
 
-10 #2 goutam krishna 2008-02-29 16:47
hi...
if u get a solution for the above problem u faced, pls provide for me also since i too facing the same
Quote
 
 
+3 #3 avesh 2008-03-26 05:52
SET PATH=C:\j2sdk1.4.2_05\bin

SET CLASSPATH=C:\j2sdk1.4.2_05\bin

SET JAVA_HOME=C:\j2sdk1.4.2_05

To solve java runtime error type above codes
Quote
 
 
-1 #4 Anil 2008-05-30 12:59
Thanks !
Quote
 
 
+101 #5 rishi 2008-07-04 09:49
in command promt go to ur folder whr ur java file exist and write this
set classpath=%classpath%;.;

best of luck for java programming.
Quote
 
 
+2 #6 ZutoKido 2008-08-03 20:16
It was really helpful! Thanks!!!
Quote
 
 
-9 #7 Jessiecca 2008-08-07 12:24
Thanks a lot... it was of great help
Quote
 
 
-2 #8 sandhya 2008-08-27 12:54
:D Thanks for this solution
Quote
 
 
+4 #9 aLumma 2008-09-03 00:12
thanks a lot!

what is the "CLASSPATH" variable doing? does it have to read "SET" in front? it doesn't here, and i dont't have the "JAVA_HOME" variable either, should i put it in??

sorry if these questions are beyond stupid, but i'm totally new to java!

.a
Quote
 
 
-4 #10 Anna 2008-09-30 14:44
Thanks a lot!!!!!!!!!!!! That was very helpfull.
Quote
 
 
-4 #11 varvar 2008-10-02 09:18
Thanks a ton dude!
even i was stuck at this silly silly point

Thanks again
Quote
 
 
+18 #12 SEKHAR 2008-10-10 09:17
hi folks ,
thanks for u r useful comments.
but any one here tell me what's the difference between these 3 paths
1.JAVA_HOME
2.CLASSPATH
3.PATH
Quote
 
 
-4 #13 thanks 2008-10-11 10:38
Thanks a lot!
Quote
 
 
-4 #14 Shamus 2008-10-22 04:07
MUCHAS GRACIAS!
Quote
 
 
-3 #15 Sneha 2008-10-23 01:34
Thank you.. This is really helpfull for me a Newbe to java.
Quote
 
 
+6 #16 Patti 2008-10-24 02:06
I did all this, but it doesn't help! This is so frustrating! HELP, please?!
Quote
 
 
+2 #17 Ali 2008-10-27 10:14
hi
i have identify an object.
i have add the jar to the netbeans.
i have import the packeg.
.
when i call a class from a jar file i get this error:

The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletExceptio n: #{GetBean.Validate}: javax.faces.el.EvaluationExcep tion: java.lang.NoClassDefFound Error: org/apache/log4j/Logger
javax.faces.webapp.FacesServlet.service(FacesSe rvlet.java:209)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(Monito rFilter.java:368)

root cause

javax.faces.FacesException: #{GetBean.Validate}: javax.faces.el.EvaluationExcep tion: java.lang.NoClassDefFound Error: org/apache/log4j/Logger
com.sun.faces.application.ActionListenerI mpl.processAction(A ctionListenerI mpl.java:78)
javax.faces.component.UICommand.broadcast(UICom mand.java:312)
javax.faces.component.UIViewRoot.broadcastEvents (UIViewRoot.java:267)
javax.faces.component.UIViewRoot.processApplicat ion(UIViewRoot.java:381)
com.sun.faces.lifecycle.InvokeApplicati onPhase.execute(InvokeA pplicati onPhase.java:75)
com.sun.faces.lifecycle.LifecycleImpl.phase(Lifecycle Impl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(Lifecyc leImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesSe rvlet.java:197)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(Monito rFilter.java:368)



please help......
:cry:
Quote
 
 
-13 #18 nisha 2008-11-10 14:20
Thanx aloooooooot.........its been a great help
Quote
 
 
+1 #19 Reaper 2008-11-10 17:32
finally it works, after searching thousands of sites on net, it solved this easy one. thx, thx, thx a lot
Quote
 
 
-3 #20 santosh kumar 2008-11-30 18:43
hi
i getting this problem
Exception in thread "main" java.lang.NoClassDefFound Error

tell how i ll remove this problem
Sponsored links:
Quote
 
 
-18 #21 mouse 2008-12-04 19:45
..wtf i just took the .class off and it worked...WHY
that makes no fucking sence...this is why i have hated java for sooo fucking long
Quote
 
 
+8 #22 Casttro 2008-12-05 11:53
PATH = The operating system will look into this
CLASSPATH = The application will look into this
Quote
 
 
-3 #23 Rishi 2008-12-08 13:18
Thanks a lot for this helpful info :-)
Quote
 
 
+2 #24 viresh 2008-12-08 18:58
classpath are used to set lib files.

path is used to store bin.

java home is just a environment variable which will be useful when u do an application on application server.
Quote
 
 
-2 #25 visakh 2008-12-15 08:59
tiny info, but very useful.
Quote
 
 
+3 #26 charu 2008-12-16 06:54
i somehow corrected my path and my prog is compiled successfully.... but now my program is not executing
it says:
D:\Softwares\or acle\product\10.2.0\client_1\jdk\bin>java d:\softwares\ja vaprograms\hell oworld
Exception in thread "main" java.lang.NoClassDefFound Error: d:\softwares\ja vaprograms\hell oworld
Quote
 
 
+5 #27 jyothi 2009-01-15 09:16
hi guys,
m unable to rectify the error even now after doing all alternative techniques.plz help me m gvng my program below:

import java.sql.*;
import java.io.*;
import java.util.*;
public class JDBCExample1{
public static void main(String args[]) throws Exception
{
FileInputStream fis=new FileInputStream ("config.properties");
Properties props=new Properties();
props.load(fis);
String vdriver=props.getProperty("driver");
String vuname=props.getProperty("uname");
String vpwd=props.getProperty("pwd");
String vurl=props.getProperty("url");
Class.forName(vdriver );
Connection con=DriverManager.getConnection(v url,vuname,vpwd );
System.out.println(con.getClass());
con.close();
}
}

config.properties

String driver=Oracle.jdbc.driver.OracleDriver
String uname=system
String pwd=tiger
String url = jdbc:oracle:thi n:@localhost:1521:-xe
Quote
 
 
+17 #28 Song Toan 2009-01-21 10:00
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;./;"

Pay attention at the "./" at the end of the paths in both solutions.

Conclusion: The java.exe does not take current directory by default! We have to add it into by ourselve!

Hope this save times of many many new guys like me!
Quote
 
 
-6 #29 lokesh 2009-01-30 18:46
thank s dude
Quote
 
 
0 #30 Ramya NR 2009-01-30 19:14
Thank u. This was a very useful solution for my long time struggle with the java s/w. Most don't know this logic. thanks again.
Quote
 
 
+6 #31 ashiq 2009-02-03 13:17
I am struck even i change the variables i am getting the same error
i am completely new to java can you help me
the error is:
Exception in thread "main" java.lang.NoClassDefFound Error: Hello
Quote
 
 
+6 #32 Dang Tuan 2009-02-13 03:30
I've tried the command: set classpath=%classpath%;.;

It works! Amazing :D

Thanks.
Quote
 
 
+3 #33 KK 2009-03-26 15:47
set classpath=%classpath%;.;

it works thanks a lot
Quote
 
 
+4 #34 Shashank Sawant 2009-05-25 09:23
I tried all the solution mentioned above but my problem still persists. Here is what I did in detail:
When I tried to compile my HelloWorldApp.java file using the following command:
javac HelloWorldApp.java
it worked (for being able to do this simple thing I had to change a lot of variables).

But then when I tried to Run the program using:
java HelloWorldApp
it gave me the error:
Exception in thread "main" java.lang.noclassdef...
...
...
...

To solve this error I tried various commands like:
set classpath=%classpath%;.;
java -classpath . HelloWorldApp
java -classpath . HelloWorldApp.class

but to no avail. Can anyone help me out with this problem?

Regards,

-sgsawant
Quote
 
 
-4 #35 Gajanan 2009-09-04 00:58
Thanks so much I had same problem. Really stupid problem which can discourage you .
Quote
 
 
-1 #36 padmakar vishe 2009-09-25 21:58
Thanks...a....lot... :-)
Quote
 
 
-1 #37 dharmendra 2009-10-03 13:48
many many thanks,
Quote
 
 
-1 #38 nano 2009-10-07 10:42
the problem was the missing dot "."
without dot, I think the JVM does not feel like searching the current working directory for the class.
YES, this can surely discourage the JAVA newbies.
I insanely wasted 1 hour over this problem in uninstalling and reinstalling the JAVA SE.
Quote
 
 
-25 #39 FARAZ 2009-10-16 11:04
I SOLVE THIS ERROR
HOW?
WAIT FOR MY NEXT COMMENT

FARAZ
Quote
 
 
+2 #40 Elridge D 2009-10-30 21:28
I was seeing this error even though i had the correct environment variables (PATH and JAVA_HOME).

I found that the issue had to do with where I was compiling my test class. I had it in a package (com.xyz.apps.test.setup), so the fix for me was that I needed to run the javac command at the same level as where the /com directory existed. I had tried to compile it from the level of where the class lived (inside /com/xyz/apps/test/setup). Also, i specified a destination directory and then ran the java command on the compiled class in that directory.
Quote
 
 
-4 #41 Jack B 2009-11-06 02:05
Thank you sooo much
Quote
 
 
+3 #42 hmmmmmmm 2009-11-25 07:36
i still dont get where to put these.. i put the CLASSPATH=.;c:\programme\j boss\lib;c:\pro gramme\
j2sdk1.4.2_08\lib;c:\pro gramme\j 2sdk1.4.2_08\jre\lib; in the variable name but whats the value.. i vid tut would be nice if you could make me one thanks :-)
Quote
 
 
-1 #43 Abhi 2009-11-26 23:31
Thanks a lot!!! :-)
Quote
 
 
-5 #44 sms 2009-11-30 07:16
It was really helpful! Thanks!!!
Quote
 
 
-6 #45 sms 2009-12-01 09:58
Error
finally it works, after searching thousands of sites on net, it solved this easy one. thx, thx, thx a lot
Quote
 
 
+2 #46 Prasad 2010-02-26 15:31
Just found out one more problem while setting up CLASSPATH
SET CLASSPATH=C:/Program Files;
and
SET CLASSPATH="C:/Program Files"; BEHAVES very differently while executing from command prompt but works fine if environment variable is set with out text qualifier ("") and IDE is used for execution
If there is space between (Like Program Files) use text qualifier “C:\Program Files\Cognos\c8 \webapps\p2pd\W EB-INF\lib” for path instead of C:\Program Files\Cognos\c8 \webapps\p2pd\W EB-INF\lib
Quote
 
 
+1 #47 pradeep 2010-04-06 07:09
the easy but illogical way of solving this
[Exception in thread "main" java.lang.NoClassDefFound Error:]
is to delete the space in between class and name and again leaving a space in between them . now save it and try it
(solves only if the path is in bin)
Quote
 
 
+1 #48 Hassan 2010-04-24 14:37
I TRIED ALL ABOVE COMMAND BUT THE SAME PROBLEM IN JAVA.LANG
Quote
 
 
0 #49 Hi Thanks for valuable comment 2010-05-05 11:34
File 1: Goo.java


import cert.*;
package book;


class Goo
{

public static void main (String [] args)
{
Sludge o = new Sludge();
o.testIt();
}
}




File 2: Sludge.java


package cert;

public class Sludge
{
public void testIt()
{

System.out.println("Sludge");
}
}


Here i have 2 files in different package called cert & book.

My files are compiled but when i try to run Goo . it gives error , although method in both prorgram are public accessifier.

Pls. Suggest.
Quote
 
 
+1 #50 Hi Thanks for valuable comment 2010-05-05 11:35
File 1: Goo.java


import cert.*;
package book;


class Goo
{

public static void main (String [] args)
{
Sludge o = new Sludge();
o.testIt();
}
}




File 2: Sludge.java


package cert;

public class Sludge
{
public void testIt()
{

System.out.println("Sludge");
}
}


Here i have 2 files in different package called cert & book.

My files are compiled but when i try to run Goo . it gives error , although method in both prorgram are public accessifier.

Pls. Suggest.
Quote
 
 
+1 #51 zero to hero 2010-05-29 22:03
your cut to cut approach of telling is gr8 i benifited frm you rather i was wasting so much tym in other websites
Quote
 
 
+6 #52 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
 
 
-1 #53 preeti 2010-07-08 21:18
m still not able to get it
plz help
:cry:
Quote
 
 
-2 #54 preeti 2010-07-08 22:04
hey it really helped me
thank u all guys
Quote
 
 
0 #55 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 #56 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 #57 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 #58 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 #59 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 #60 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 #61 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 #62 Mani Prakash 2010-07-27 11:50
Thanks a lot. it works
Quote
 
 
-1 #63 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 #64 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
 
 
0 #65 Satyadeep 2010-08-07 19:50
:-) Thank you very much
That had made my day
Quote
 
 
-3 #66 unknownq 2010-08-12 12:34
Quoting Deepak:
It was really helpful. Thanks a lot. 8)
really worked
Quote
 
 
-4 #67 Neeraj 2010-08-27 10:39
Thanks a lot..it really worked..
Quote
 
 
-4 #68 Mitul_Patel 2010-09-01 05:59
Thanks man great help
Quote
 
 
-3 #69 Avinash Bikumalla 2010-09-03 03:14
Thanks for the solution :-) :-)
Quote
 
 
+2 #70 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 #71 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 #72 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 #73 Sasmita 2010-10-10 03:46
thanks... a lot :lol: :D :roll:
Quote
 
 
-1 #74 Praddy 2010-10-11 17:47
Helped a lot! thank you! 8)
Quote
 
 
-3 #75 udita 2010-10-14 15:16
ohh ..thnk u soo mucchh .. it was of great help.
Quote
 
 
0 #76 udita 2010-10-14 15:17
thnxx gr8 help .. :)
Quote
 
 
0 #77 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 #78 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 #79 sandysam 2010-10-20 16:08
THANKS A LOT!!!!
It was very helpfull!!!!! :D :lol:
Quote
 
 
+2 #80 neera singh 2010-12-23 06:12
thanks a ton :lol:
Quote
 
 
+1 #81 neera singh 2010-12-23 07:26
thanks a ton it worked.......... :lol:
Quote
 
 
0 #82 Shaahid 2011-01-02 20:22
Thanks a lot for the info. Its working
Quote
 
 
0 #83 Sadiksha 2011-01-04 07:01
Thanks a lot, it really worked..... :lol: :-) :D
Quote
 
 
0 #84 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 #85 Preeti 2011-01-25 09:56
Really helpful.Thanks :)
Quote
 
 
+1 #86 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 #87 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 #88 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
 
 
+2 #89 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
 
 
+2 #90 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 #91 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 #92 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 #93 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
 
 
+2 #94 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 #95 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
 
 
-1 #96 hmmm 2011-07-12 14:58
thank you very much
Quote
 
 
0 #97 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 #98 hooray 2011-07-18 15:33
thanks!! solved the error!!
Quote
 
 
+1 #99 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 #100 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 #101 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 #102 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
 
 
+1 #103 vignes 2011-08-15 07:34
your single line clear all my errors Thanks a lot RISHI
Quote
 
 
-1 #104 vignes 2011-08-15 07:35
your single line clears all my errors thankyou very much
Thanks RISHI
Quote
 
 
+6 #105 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 #106 abcds 2011-09-07 06:22
here is another good article on how to resolve ClassnotFoundEx ception in java
Quote
 
 
+3 #107 ryalir 2011-09-08 15:06
Quoting KK:
set classpath=%classpath%;.;

it works thanks a lot

Thanks a lot yar
Quote
 
 
+1 #108 vibhu 2011-09-09 09:57
8) Thanks :)
Quote
 
 
-2 #109 kratnesh 2011-09-09 10:01
how to set classpath for jdbc application in fedora 15
Quote
 
 
+2 #110 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 #111 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
 
 
+1 #112 Someshwar 2011-12-15 06:15
It really helped, thanks a lot for the info.
Quote
 
 
+1 #113 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 #114 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 #115 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 #116 preeti 2012-01-23 12:18
thanks for the solution........my code worked!!!!!!!!! !!!thanks again
Quote
 
 
+1 #117 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 #118 shiju 2012-02-04 06:25
thanks rishi thanks a lot.
Quote
 
 
+1 #119 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 #120 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 #121 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 #122 jerrylyn 2012-02-25 07:05
thank you so much...
Quote
 
 
+1 #123 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 #124 deepika 2012-03-03 13:47
i tried set classpath=%classpath%;.; but still iam getting noclassdeffound help me in resolving this
Quote
 
 
+1 #125 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
 
 
+1 #126 ajith 2012-03-28 15:42
thank you buddy :lol:
this solution set classpath=%classpath%;.; works for me : :P
Quote
 
 
0 #127 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 #128 Toughs 2012-04-11 12:32
set classpath=%classpath%;.;
8) Worked!
Quote
 
 
-1 #129 LakshmiPriya 2012-04-16 19:35
Thanks so much.... That was great help!! :-)
Quote
 
 
+2 #130 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 #131 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 #132 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 #133 ichi 2012-05-02 02:42
set CLASSPATH =% CLASSPATH%;.;
javac Hello.java
java Hello
thanks!! :lol:
Quote
 
 
0 #134 sanjay sj 2012-05-02 19:43
thanx :-)
Quote
 
 
0 #135 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
 
 
+1 #136 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
 
 
+1 #137 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 #138 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 #139 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 #140 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 #141 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 #142 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 #143 bjthom 2013-04-23 00:45
DON'T LISTEN TO ME! That solution seems to work.
Quote
 
 
0 #144 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 #145 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 #146 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 #147 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 #148 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 #149 Panel Beaters Westra 2013-12-16 14:02
your blog is very nice i like it
Quote
 
 
+1 #150 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
 

Add comment


Security code
Refresh


Recommended:
Codegravity.com featured at:

greeklug.gr

inadeh.edu.pa

jhev.gov.my

langu-sistemos.lt

salamandra.org.pl

zalamat.hu

natpemarket.com

mr-it.biz

stitchnationyarn.com

voceabasarabiei.net

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