Link to home
Start Free TrialLog in
Avatar of yugandhar
yugandhar

asked on

Exception in Thread main

After compiling the programming under DOS-prompt,getting the "Exception in Thread main:java.lang.NoClassDefFoundError",please explain the reason behind this error?The program is not running after getting this Error.
Avatar of yugandhar
yugandhar

ASKER

This is very nice site to find for getting  answers.Thanks for introducing this site.Please reply me as early as possibe.
specify CLASSPATH
Hi yugandhar,

1. The exception will come when the class you are trying to run is not  in your classpath.

Check wheter the current directory was set in classpath.

like

classpath = .;c:\jdk118\lib\classes.zip;
.. indicates current directory

2. Check the file name  and class name in that file name which contain

public static void main(String args[]) is same or not.

Best of luck
The possible reasons cud be,

1. Classpath was not set properly
    jdk1,2 does not use classes.zip in that case u shud set the classpath to java_home\lib;
i.e
SET CALSSPATH=C:\JDK1.2\LIB;


2. Java compilation is done thru,
    >javac XXX.java
   Java execution is done thru
   >java XXX
 
NOTE: please make sure that u did not say java XXX.class
..class shud not be given while running ur program

-sgoms
Avatar of Jan Louwerens
.and the obvious, of course: make sure the class you are trying to run actually contains a 'main' method
set your classpath variable,for more ref.visit the foll..site
http://java.sun.com/products/jdk/1.2/docs/tooldocs/win32/classpath.html
shaveri, setting the correct classpath has been stated by many experts. what made u propose an answer? please post a comment & let the person who asked the question decide for himself/herself which is a suitable answer.

no offense meant.
-sgoms
shaveri,
 You proposed the  same answer as others  did.I am sorry to say it is not appropriate. Thank you.
 yugandhar
did u chk whether u stated it as java <filename> or java <filename>.class??

does the problem still persist?

-sgoms
did u chk whether u stated it as java <filename> or java <filename>.class??

does the problem still persist?

-sgoms
Regarding my question ,the problem is
still there,Igot over that problem last
week.Now recurring ,the same.the question no.is 10246200-2290141.Thankful to all who answered this  Qn.I will  add 60 pts.if i get
 correct answer.
Hi,

 Once post

 Your classpath,path and your code and filename.

IT's a very simple problem.

BEst of luck
post your classpath,path and your code and filename & ur steps.

-sgoms
Hi,

I agree with what ever sqoms says.r all ur programs not running or only this prg.

check the declaration of main().
It should be
 public static void main(String args[]){

   //code.........

}

Set the class path in ur Autoexec.bat as:

path=C:\jdk1.2\bin;C:\jdk1.2\lib

Run the Autoexec.bat once......

Even then if u r getting the problem check installation of JRE and jdk1.2.

Else post ur code....


Try it..............

ASKER CERTIFIED SOLUTION
Avatar of vivexp
vivexp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial