[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Exception in Thread main

Posted on 1999-12-13
15
Medium Priority
?
276 Views
Last Modified: 2010-03-30
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.
0
Comment
Question by:yugandhar
  • 5
  • 3
  • 2
  • +4
15 Comments
 

Author Comment

by:yugandhar
ID: 2277040
This is very nice site to find for getting  answers.Thanks for introducing this site.Please reply me as early as possibe.
0
 
LVL 7

Expert Comment

by:vladi21
ID: 2277071
specify CLASSPATH
0
 
LVL 7

Expert Comment

by:Ravindra76
ID: 2277157
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
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 5

Expert Comment

by:sgoms
ID: 2277395
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
0
 
LVL 7

Expert Comment

by:Jan Louwerens
ID: 2277938
.and the obvious, of course: make sure the class you are trying to run actually contains a 'main' method
0
 
LVL 2

Expert Comment

by:shaveri
ID: 2279092
set your classpath variable,for more ref.visit the foll..site
http://java.sun.com/products/jdk/1.2/docs/tooldocs/win32/classpath.html
0
 
LVL 5

Expert Comment

by:sgoms
ID: 2279122
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
0
 

Author Comment

by:yugandhar
ID: 2290058
shaveri,
 You proposed the  same answer as others  did.I am sorry to say it is not appropriate. Thank you.
 yugandhar
0
 
LVL 5

Expert Comment

by:sgoms
ID: 2290141
did u chk whether u stated it as java <filename> or java <filename>.class??

does the problem still persist?

-sgoms
0
 
LVL 5

Expert Comment

by:sgoms
ID: 2290144
did u chk whether u stated it as java <filename> or java <filename>.class??

does the problem still persist?

-sgoms
0
 

Author Comment

by:yugandhar
ID: 2299587
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.
0
 
LVL 7

Expert Comment

by:Ravindra76
ID: 2299748
Hi,

 Once post

 Your classpath,path and your code and filename.

IT's a very simple problem.

BEst of luck
0
 
LVL 5

Expert Comment

by:sgoms
ID: 2300175
post your classpath,path and your code and filename & ur steps.

-sgoms
0
 
LVL 1

Expert Comment

by:vivexp
ID: 2311558
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..............

0
 
LVL 1

Accepted Solution

by:
vivexp earned 180 total points
ID: 2340605
Hi,


Thrown if the Java Virtual Machine or a classloader tries to load in the definition of a class (as part of a normal method call or as
part of creating a new instance using the new expression) and no definition of the class could be found.

The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.


If not satisfied Post ur code...

Bye...



0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month11 days, 2 hours left to enroll

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question