Home » Developer & Programmer » JDeveloper, Java & XML » Exception in thread "main" java.lang.NoClassDefFoundError
Exception in thread "main" java.lang.NoClassDefFoundError [message #91179] Thu, 16 May 2002 23:10 Go to next message
Karthikeyan
Messages: 12
Registered: December 2001
Junior Member
I installed J2SDK1.4.0 and J2EE server also. When I run
the simple program just "HelloWorld", I got the
error like that
Exception in thread "main" java.lang.NoClassDefFoundError : HelloWorld

Can somebody help to solve this problem Please?
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91182 is a reply to message #91179] Fri, 17 May 2002 06:00 Go to previous messageGo to next message
lenon
Messages: 5
Registered: May 2002
Junior Member
add current directory "." in your classpath
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91281 is a reply to message #91179] Sun, 30 June 2002 20:52 Go to previous messageGo to next message
Martin
Messages: 83
Registered: February 2000
Member
Hi,

I have same error as you had, could you please show me what you resolved for this error message.

Exception in thread "main" java.lang.NoClassDefFoundError

Thank you for your help
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91289 is a reply to message #91179] Tue, 02 July 2002 21:25 Go to previous messageGo to next message
Javcafe
Messages: 1
Registered: July 2002
Junior Member
I have added current directory "." in my classpath already, but the error still went on.
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91295 is a reply to message #91289] Wed, 03 July 2002 06:19 Go to previous messageGo to next message
JavPlam
Messages: 1
Registered: July 2002
Junior Member
Hi, I had the same problem after installing J2SDK1.4.0_01. But I also fixed it by adding the current /bin directory to my classpath:
I just inserted an additional row in the autoexec.bat
"SET CLASSPATH=c:j2sdk1.4.0_01BIN" , saved the file and run c:autoexec.bat
After that everything was OK.

Hope it helps.
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91303 is a reply to message #91179] Fri, 05 July 2002 01:23 Go to previous messageGo to next message
guruswamy
Messages: 1
Registered: July 2002
Junior Member
java.long.NoClassDefFoundError
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91317 is a reply to message #91179] Fri, 12 July 2002 12:08 Go to previous messageGo to next message
CJ Singh
Messages: 1
Registered: July 2002
Junior Member
adding the bin directory in classpath definitely works
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91329 is a reply to message #91179] Mon, 15 July 2002 17:25 Go to previous messageGo to next message
Gerardo E. Casasola
Messages: 1
Registered: July 2002
Junior Member
I have installed j2sdk1.4.0_01 in Windows XP environment. I have set the CLASSPATH as "C:j2sdk1.4.0_01bin;C:j2sdk1.4.0_01libtools.jar", but I still get the same run-time error.

Could somebody help me?

Thank you.
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91331 is a reply to message #91179] Tue, 16 July 2002 04:55 Go to previous messageGo to next message
Alex
Messages: 190
Registered: August 1999
Senior Member
CLASSPATH=.;C:Progra~1Javaj2re1.4.0_01lib;D:Forte_jdkj2sdk1.4.0_01lib
You must delete file extension ".class" from command line, for example:
[[Folder for your program]]>java Example
And all will be good! Hi.
Re: Exception in thread [message #91345 is a reply to message #91179] Tue, 23 July 2002 12:04 Go to previous messageGo to next message
Ishai
Messages: 1
Registered: July 2002
Junior Member
I have the c:jdkbin in my path but it still doesnt work , can someone
help me out ?
i cant run any program :-\

and plz write the full explaination because otherwise its hard to understand what your writing .
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91437 is a reply to message #91179] Wed, 04 September 2002 09:19 Go to previous messageGo to next message
Paradorn
Messages: 1
Registered: September 2002
Junior Member
Thanks so much!!!!!
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91442 is a reply to message #91179] Mon, 09 September 2002 02:45 Go to previous messageGo to next message
Prabhu
Messages: 26
Registered: October 2001
Junior Member
The Error Message
"Exception in thread "main" java.lang.NoClassDefFoundError:" is because the JVM is not able to locate the Class file which you are trying to Run (though you are in the Directory where your class file is placed.)

To solve this issue the solution is set the CLASSPATH variable to your current directory(Open Command prompt key in the following and press Enter
"Set Classpath=%Classpath%;.;
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91448 is a reply to message #91179] Tue, 10 September 2002 06:33 Go to previous messageGo to next message
David
Messages: 110
Registered: November 1998
Senior Member
I installed J2SDK1.4.0 and J2EE server also. When I run
the simple program just "HelloWorld", I got the
error like that
Exception in thread "main" java.lang.NoClassDefFoundError : HelloWorld

Did you get the solution for this problem I set classpath to the bin and Lib directory and nothing happen I am running J2sdk1.4 on windows2000 professional
Exception in thread "main" java.lang.NoClassDefFoundError [message #91450 is a reply to message #91179] Tue, 10 September 2002 21:36 Go to previous messageGo to next message
Brian
Messages: 38
Registered: October 1999
Member
Hi

I have installed j2sdk-1_3_1_02 under windows ME OS.
I just run a simple HelloWorld program but keep getting
the message Exception in thread "main" java.lang.NoClassDefFoundError. I set my environment like this:
PATH=C:jdk1.3.1_02bin;
CLASSPATH=C:jdk1.3.1_02lib;
JAVA_HOME=C:jdk1.3.1_02bin;

Please help me to solve this problem. Thank
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91452 is a reply to message #91450] Wed, 11 September 2002 14:06 Go to previous messageGo to next message
Sean
Messages: 22
Registered: July 2000
Junior Member
Try this CLASSPATH=C:jdk1.3.1_02lib;.;
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91455 is a reply to message #91179] Sun, 15 September 2002 05:14 Go to previous messageGo to next message
Raphael
Messages: 2
Registered: January 2001
Junior Member
Had the same problem.
Try to run "java name" , name is you class-File without the .class at the end
For example java HelloWorld
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91458 is a reply to message #91179] Tue, 17 September 2002 13:00 Go to previous messageGo to next message
mercebranda
Messages: 1
Registered: September 2002
Junior Member
HINTS

1) If your on NT e.g., don't use command processor filename completion.
2) Use correct capitalization of class name on command line.
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91460 is a reply to message #91179] Wed, 18 September 2002 10:38 Go to previous messageGo to next message
Diana Benobo
Messages: 1
Registered: September 2002
Junior Member
If you are using NT 2000 ...

Try these with attention to case:

java -cp myjar.jar myapplet
java -cp c:myclassesmyjar.jar myapplet

java -cp myjar.jar mypackage.myapplet
java -cp c:myclassesmyjar.jar mypackage.myapplet

Setting the classpath variable on NT 2000 didn't seem to help me to shorten the path for the -cp variable unless I set the classpath to specifically to the jar itself, as follows:

set classpath=c:myclassesmyjar.jar

or possibly

set classpath=c:myclassesmyjar;%classpath%

If you set a classpath environmental variable by using the command line above, don't use spaces on either side of the equals sign. The set command will interpret the space as a character.

Note: Be sure to observe the case of the classpath variable name ( CLASSPATH, classpath, ClassPath, etc.)
before you set the classpath or else you may end up with two classpath variables.
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91466 is a reply to message #91179] Wed, 25 September 2002 07:39 Go to previous messageGo to next message
vimal
Messages: 46
Registered: February 2000
Member
Yes I am also having the same problem...I have installed J2SDk1.4.0 on Windows 2000 Professional.When I try to run the Hello World program it gives the error message
"Exception in thread "main" java.lang.NoClassDefFoundError : Hello

Can somebody help me out?.

Thanks,

Vimala
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91476 is a reply to message #91179] Sun, 29 September 2002 16:51 Go to previous messageGo to next message
Drew
Messages: 3
Registered: September 2002
Junior Member
Whew long thread!

Overview of solution:
Ensure that you run you class file without the .class extention... ie. c:>java HelloWorld
Ensure that your current directory is included in ClassPath... ie. C:>set ClassPath=%ClassPath%;.;
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91480 is a reply to message #91179] Tue, 01 October 2002 21:35 Go to previous messageGo to next message
Vic
Messages: 8
Registered: August 2000
Junior Member
I get the same error, trying to run the java executable on Solaris. Can someone hlep me set Solaris environment variables?
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91493 is a reply to message #91480] Tue, 08 October 2002 12:26 Go to previous messageGo to next message
Raajit Lall
Messages: 1
Registered: October 2002
Junior Member
Raajit Lall
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91497 is a reply to message #91179] Wed, 09 October 2002 15:23 Go to previous messageGo to next message
JOHN
Messages: 182
Registered: April 1998
Senior Member
I tried every one of these "CLASSPATH" solutions. I still get the error. Does anyone out there know how to solve this problem. If so, please state the entire solution so we can follow step by step.

Thanks.
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91503 is a reply to message #91179] Sat, 12 October 2002 06:06 Go to previous messageGo to next message
Peter
Messages: 62
Registered: August 2000
Member
when I compile my program I get like this:
Exception in thread "main" java.lang.NoClassDefFoundError: LineDrawing1 (wrong n
ame: lineDrawing1).
--------------------------------
please help me
tanks
Peter
% [message #91504 is a reply to message #91179] Sat, 12 October 2002 06:23 Go to previous messageGo to next message
Peter
Messages: 62
Registered: August 2000
Member
I have got some problem whit (%).
I donīt know how it dose work.
tanks
Peter
Re: Exception in thread "main" java.lang.NoClassDefFoundError (win 2000) [message #91508 is a reply to message #91179] Tue, 15 October 2002 03:47 Go to previous messageGo to next message
Claudio Joao
Messages: 1
Registered: October 2002
Junior Member
I just installed j2sdk1.4.1 on my windows 2000 machine.
My CLASSPATH now looks like this "C:j2sdk1.4.1libtools.jar;.;" and it works nice.
However if you place the current directory "." BEFORE "C:j2sdk1.4.1libtools.jar" it stops working and I'm back to those
"java.lang.NoClassDefFoundError" errors again.
Must be a windows feature.So try with the "." at the end of the CLASSPATH
It worked for me I hope it works for you.
Claudio
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91561 is a reply to message #91476] Fri, 08 November 2002 19:34 Go to previous messageGo to next message
me
Messages: 66
Registered: August 2000
Member
Thankyou for solving my problem right after i did the second part of your message of your Re: I fixed it and it worked tx bye
Re: Exception in thread "main" java.lang.NoClassDefFoundError (win 2000) [message #91582 is a reply to message #91508] Fri, 29 November 2002 15:49 Go to previous messageGo to next message
Raschin
Messages: 1
Registered: November 2002
Junior Member
I have the same problem, but the "." at the end didn't solve my problem.
Has anyone another idea?
I'm trying it a few weeks now but it will not work nobody can help, so i'd be glad about a little tip...
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91601 is a reply to message #91182] Thu, 05 December 2002 16:15 Go to previous messageGo to next message
Dave
Messages: 92
Registered: August 1999
Member
dont->

java Whatever.class

do

java Whatever
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91660 is a reply to message #91329] Wed, 01 January 2003 13:22 Go to previous messageGo to next message
Jayme Fishman
Messages: 1
Registered: January 2003
Junior Member
Try setting the environmental variables, see this site for details.
http://www.cs.wfu.edu/~pauca/csc111/instructions.html
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91671 is a reply to message #91442] Mon, 06 January 2003 17:13 Go to previous messageGo to next message
Lakshmi mandaleeka
Messages: 1
Registered: January 2003
Junior Member
Your JAVA_HOME should be set to JAVA_HOME=C:jdk1.3.1_02; not JAVA_HOME=C:jdk1.3.1_02bin;
Thats one of the problems.
CLASSPATH need not be set to C:jdk1.3.1_02lib; from 1.3. This is an old convention, however u need to set it to your current dir or directory where your .class has been compiled to.
The above changes should resolve your problem.
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91675 is a reply to message #91179] Tue, 07 January 2003 09:12 Go to previous messageGo to next message
Rune
Messages: 1
Registered: January 2003
Junior Member
My classpath was FUBAR; make sure it's set to currentdir (".")! :)
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91705 is a reply to message #91179] Wed, 15 January 2003 08:51 Go to previous messageGo to next message
Alejandro Sandoval Rivera
Messages: 1
Registered: January 2003
Junior Member
How I eliminate this mistake?
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91737 is a reply to message #91179] Sun, 26 January 2003 00:06 Go to previous messageGo to next message
Paul
Messages: 164
Registered: April 1999
Senior Member
I was having the same problem until I changed to the same directory as the Hello World file.

from the directory that the HelloWorld.class file is in, run java HelloWorld.

For example, mine is as follows:

C:javajava HelloWorld

Works fine.
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91741 is a reply to message #91179] Wed, 29 January 2003 01:47 Go to previous messageGo to next message
Karthik Durai
Messages: 2
Registered: December 2002
Junior Member
Set Ur program name in Classpath.
EX:
My program name is DB1.java. I run like this
1) c:karthikwrkjavajava DB1
--> It gave java.lang.NoClassDefFoundError
SOLUTION;
2) Then i set this in my classpath
-->C:karthikwrkjava>set CLASSPATH=%CLASSPATH%;c:oraclejdbclibclasses12.zip;c:karthikwrkjava;

Now it is working fine.
--Karthik
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91743 is a reply to message #91179] Thu, 30 January 2003 00:43 Go to previous messageGo to next message
JGriffin
Messages: 1
Registered: January 2003
Junior Member
I deleted the environment variable CLASSPATH and now it works fine. Also you could add .; to the classpath to make it work from what I understand. Class path is found ( WINDOWS XP ) in the control panel -> Performance and Maitenance -> System -> System Properties -> Environmental Variables
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91746 is a reply to message #91179] Thu, 30 January 2003 14:31 Go to previous messageGo to next message
Brad Sorensen
Messages: 1
Registered: January 2003
Junior Member
WINDOWS 2000

************************************
STEP ONE
Locate the BIN directory in the sdk version you are using

(I installed j2ee and j2se and ant)

MY LOCATIONS:
(J2SE) C:j2sdk_1.4.1_01bin
(J2EE) C:j2sdkee1.4bin
(ant) C:jakarta-ant-1.3bin
************************************

************************************
STEP TWO
Under Start | Settings | Control Panel, Double click 'System'
Navigate to the 'Advanced Tab' and select 'Environmental Variables'

- Under 'System Variables' Select CLASSPATH and click EDIT
- add ';.' to the end of the string already there.
- Click 'OK'

- Under 'System Variables' select PATH and click EDIT
- add ';C:j2skd1.4.1_01/bin;C:j2skdee1.4bin;C:jakarta-ant-1.3bin;' (or just the sdk you are using) to the end of the string already there.
- Click 'OK'
************************************

If that doesn't work,
Cry

Brad
Alternate way to execute your program [message #91748 is a reply to message #91179] Fri, 31 January 2003 09:40 Go to previous messageGo to next message
SamIAm
Messages: 1
Registered: January 2003
Junior Member
Have you set your path and classpath environment variables and your application is still not executing without the error message? Consider, then, another way of executing your application.

Instead of just running it like this:

c:JavaSourceDirectory>java HelloWorld

Try this:

c:JavaSourceDirectory>java -classpath . HelloWorld

the -classpath switch sets the search path for application classes and resources. In this example, it's set to "." which is the current directory.

You can activate the -classpath switch during compilation (when you run "javac") and execution (when you run "java"), but on execution you can abbreviate it to "-cp":

c:JavaSourceDirectory>java -cp . HelloWorld

I use j2sdk1.4.1_01 on an NT platform, and this worked for me. Hope it works for you.
Re: Exception in thread "main" java.lang.NoClassDefFoundError [message #91764 is a reply to message #91179] Fri, 07 February 2003 12:33 Go to previous messageGo to next message
Sean Anderson
Messages: 1
Registered: February 2003
Junior Member
i got this errror when I specified the the ext of the program i was trying to run

ex..

c:>java myfirstjavaprog.class
not good

c:>java myfirstjavaprog
works great!

this boggled me.
Do not forget to Compile your program! [message #91769 is a reply to message #91179] Sun, 09 February 2003 04:39 Go to previous messageGo to previous message
Axel
Messages: 3
Registered: December 2001
Junior Member
Many users just simply forget to compile
before running the program.

use:

javac yourprogram
Previous Topic: Calling stored procedures in ASP
Next Topic: java.sql.SQLException: Protocol violation
Goto Forum:
  


Current Time: Fri Apr 26 05:00:28 CDT 2024