Register | Log in | Password |

365 projects | 71 services | 215 websites | 1073 freelancers | 2755 topics | advertise


Purchase JoomlaWatch:
30 day money-back guarantee
Read more...
9 EUR lifetime license
Buy Now

15 EUR lifetime license
Buy Now
(nofollow link from sponsors page)

Login:

23.4%United States United States
15.4%India India
7.3%Russian Federation Russian Federation
7.1%Colombia Colombia
6.1%Germany Germany
5.2%United Kingdom United Kingdom
4.4%Poland Poland
3.5%Netherlands Netherlands
3.1%France France
2.9%Canada Canada

Today: 154
Yesterday: 1413
This Week: 8217
Last Week: 10267
This Month: 4857
Total: 28171

Users

Most active users today from total of 8:
mlewis, Gomjerk, swaffel, specialone, leoaraujo, hanji, Denclub, fddeltenre
About JoomlaWatch:
JoomlaWatch is popular joomla visitor tracking and live stats component. It provides several features such as spam blocking, goals tracking, charts, nightly email reports, latest visit map, interactive HTML5 traffic flow graph and many other useful functionalities, which will help you to optimize your site.
RSS Feeds:

rss Freelance
rss Projects
rss Forum
rss Resources

Home

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  

 
+26 #1 Deepak 2008-01-31 13:51
It was really helpful. Thanks a lot. 8)
Quote
 
 
-6 #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
 
 
-4 #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
 
 
+50 #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
 
 
-1 #6 ZutoKido 2008-08-03 20:16
It was really helpful! Thanks!!!
Quote
 
 
-4 #7 Jessiecca 2008-08-07 12:24
Thanks a lot... it was of great help
Quote
 
 
0 #8 sandhya 2008-08-27 12:54
:D Thanks for this solution
Quote
 
 
+3 #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
 
 
0 #10 Anna 2008-09-30 14:44
Thanks a lot!!!!!!!!!!!! That was very helpfull.
Quote
 
 
+1 #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
 
 
+1 #13 thanks 2008-10-11 10:38
Thanks a lot!
Quote
 
 
+1 #14 Shamus 2008-10-22 04:07
MUCHAS GRACIAS!
Quote
 
 
+1 #15 Sneha 2008-10-23 01:34
Thank you.. This is really helpfull for me a Newbe to java.
Quote
 
 
0 #16 Patti 2008-10-24 02:06
I did all this, but it doesn't help! This is so frustrating! HELP, please?!
Quote
 
 
+1 #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
 
 
-10 #18 nisha 2008-11-10 14:20
Thanx aloooooooot.........its been a great help
Quote
 
 
-3 #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
 
 
-11 #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
 
 
+4 #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
 
 
0 #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
 
 
-1 #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
 
 
+3 #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
 
 
+9 #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
 
 
-4 #29 lokesh 2009-01-30 18:46
thank s dude
Quote
 
 
-1 #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
 
 
+4 #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
 
 
+3 #32 Dang Tuan 2009-02-13 03:30
I've tried the command: set classpath=%classpath%;.;

It works! Amazing :D

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

it works thanks a lot
Quote
 
 
+3 #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
 
 
-3 #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
 
 
-13 #39 FARAZ 2009-10-16 11:04
I SOLVE THIS ERROR
HOW?
WAIT FOR MY NEXT COMMENT

FARAZ
Quote
 
 
+1 #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
 
 
-3 #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
 
 
-4 #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
 
 
0 #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
 
 
0 #48 Hassan 2010-04-24 14:37
I TRIED ALL ABOVE COMMAND BUT THE SAME PROBLEM IN JAVA.LANG
Quote
 
 
+1 #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
 
 
+3 #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
 
 
-3 #53 preeti 2010-07-08 21:18
m still not able to get it
plz help
:cry:
Quote
 
 
-3 #54 preeti 2010-07-08 22:04
hey it really helped me
thank u all guys
Quote
 
 
+1 #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
 
 
-2 #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
 
 
0 #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
 
 
-2 #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
 
 
-2 #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
 
 
+2 #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
 
 
+1 #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
 
 
-4 #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
 
 
-4 #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
 
 
-4 #69 Avinash Bikumalla 2010-09-03 03:14
Thanks for the solution :-) :-)
Quote
 
 
0 #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
 
 
+3 #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
 
 
0 #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
 
 
-2 #73 Sasmita 2010-10-10 03:46
thanks... a lot :lol: :D :roll:
Quote
 
 
-2 #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
 
 
-1 #76 udita 2010-10-14 15:17
thnxx gr8 help .. :)
Quote
 
 
-1 #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
 
 
+1 #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
 
 
+1 #79 sandysam 2010-10-20 16:08
THANKS A LOT!!!!
It was very helpfull!!!!! :D :lol:
Quote
 
 
+1 #80 neera singh 2010-12-23 06:12
thanks a ton :lol:
Quote
 
 
0 #81 neera singh 2010-12-23 07:26
thanks a ton it worked.......... :lol:
Quote
 
 
-1 #82 Shaahid 2011-01-02 20:22
Thanks a lot for the info. Its working
Quote
 
 
-1 #83 Sadiksha 2011-01-04 07:01
Thanks a lot, it really worked..... :lol: :-) :D
Quote
 
 
-1 #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
 
 
-1 #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
 
 
-1 #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
 
 
0 #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
 
 
-1 #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
 
 
-1 #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
 
 
0 #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
 
 
-3 #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
 
 
-1 #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
 
 
0 #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
 
 
0 #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
 
 
0 #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
 
 
-1 #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
 
 
0 #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
 
 
0 #112 Someshwar 2011-12-15 06:15
It really helped, thanks a lot for the info.
Quote
 
 
0 #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
 
 
+1 #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
 
 
0 #116 preeti 2012-01-23 12:18
thanks for the solution........my code worked!!!!!!!!! !!!thanks again
Quote
 
 
0 #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
 

Add comment


Security code
Refresh


no license?

Recommended: (advertise)
Joomlawatch 1.2.17 Demo (PRO: 9/15 EUR)
Download Joomlawatch 1.2.17 (PRO: 9/15 EUR)

Rate this extension ...


Stay in touch:

New article about JoomlaWatch Live Stats feature: (link)
16 hours ago from web

Tested versions 1.2.12 FREE, 1.2.17 PRO, 1.2.18 BETA on Joomla 2.5 and older Joomla 1.5 - confirmed to work on both Joomla versions

Small installer fixes - added JoomlaWatch compatibility with Joomla 2.5

New article on JoomlaWatch Traffic Flow feature: (link) ... All features of JoomlaWatch will be documented this way.

Another minor fixes for version 1.2.17 and 1.2.18, added functionality to display only changed values in SEO report - important keyprases
2 weeks ago from web

Minor fixes for JoomlaWatch version 1.2.17 (language files), you can find the latest package in customer zone ((link)
2 weeks ago from web

If you'd like to help with testing of the latest 1.2.18 BETA with new features (Joomla/Wordpress),please add me on skype: matto3c.Thank you!
3 weeks ago from web

New article on JoomlaWatch SEO (Search Engine Optimization) report functionality - (link)

JoomlaWatch 1.2.18 is out now! Features new click heatmap feature, SEO report - how people find you on google, and many other improvements

Reorganized the menu items. Now you'll be able to easily find most requested links

JoomlaWatch 1.2.18 BETA now ready! Main features: - Heatmap integration - SEO reports - Anti-spam section visualization (link)

Fixed one issue: no unique visits recorded; PHP $_SERVER['REMOTE_ADDR'] doesn't always return remote IP address! using HTTP_X_FORWARDED_FOR

Christmas Special - 19% OFF from all licenses until 25th of December 2011

JoomlaWatch Heatmap functionality nearly done. Works with all client resolutions. Will be available in next version. (link)

Simple customer zone - (link) is now ready. Users who purchased the PRO version can now download newest version from there.

Because of the problems with payments and forwarding. We are using (link) service to deliver you the files after purchase.

Tracking Expenses from SMS android application is now published on android market :) and it's completely free !

(link) user information now protected with UserCrypt 1.1

UserCrypt version 1.1 released: Added query log, jos_users decryption on database interceptor plugin deactivation (link)

Timezone issue now fixed. Tested on canadian server which has hosting in the USA. Also module class suffix parameter now works for J1.7



Partners:
Freelance ColdFusion, Flex, PHP

Olejomalby, abstraktne obrazy

Camping Europe

WinAsm Studio

Vyšné Ružbachy

Sochy, Reštaurovanie

R.E.M.

Valid XHTML 1.0 Transitional

RSS feed:

Statistics:
Search Engine Genie Promotion Widget
Privacy policy | Advertise | Donate

Locations of visitors to this page


©2003-2010 Codegravity.com