could not find the main class. Program will exit.
java.lang.NoClassDefFoundError:
Exception in thread "main"
this is the error when i'm compiling my programs.
plz help.:(happy)::)-::o:
Printable View
could not find the main class. Program will exit.
java.lang.NoClassDefFoundError:
Exception in thread "main"
this is the error when i'm compiling my programs.
plz help.:(happy)::)-::o:
Whle *compiling* your program? Eclipse takes care of all classpath settings and issue, that's what a proper ide is supposed to do. Maybe you can elaborate on this a bit?
kind regards,
Jos
the problem is you saved your program with another class name
save the program with class that contains your main function
eg.
save program with mymain.javaCode:class my
{
}
class mymain
{
public static void main(String ar[])
{
}
}
Is that all of the error message?
Usually the message contains the name of the missing class:
java.lang.NoClassDefFoundError: THEMISSINGCLASS
java.lang.NoClassDefFoundError: packagename/classname
Exception in thread "main"
this is the complete msg.
this must not be the problem...
i hav successfully compiled my programs before with the different names on the same ide.
my IDE was working correctly but 3 days back i removed the SDK from my system. since then it is unable to compile the program bcz it was unable to find the JRE.
then i installed SDK again in the system. even then it was unable to compile.
then somehow i managed to set the path yesterday,( i don't know how) & it started to compile but even was unable to debug.
BUT 2 hrs back it suddenly start displaying the same error.
what to do now???
Eclipse doesn't need a SDK/JDK so it doesn't rely on one. Also, removing a JDK doesn't remove your JRE (on wich your Eclipse does rely). Your description of the symtoms doesn't make much sense; all I can guess is that your Eclipse is posessed, bewitched.
kind regards,
Jos
Here is what I get for an error message when there is no .class file:
Where did you get the message you posted in post#5Quote:
Running: D:\Java\jdk1.6.0_25\jre\bin\java.exe -Xmx512M MyPackage.BombGame
java.lang.NoClassDefFoundError: MyPackage/BombGame
Is your class really named: classname
and your package: packagename?
when i'm compiling my program a dialog box named "java virtual machine launcher" is generating with error
could not find the main class. Program will exit.
and the error in console is
java.lang.NoClassDefFoundError: ducat/UniqueSet
Exception in thread "main"
ducat is package name & UniqueSet is classname
That's strange. That looks like an execution time error.Quote:
when i'm compiling my program
Do you know the difference between compiling your program and executing your program?
Or does the IDE hide all that?
Eclipse doesn't hide anything at all, i.e. it shows each and every compilation error in the margins of your source text and it complains when you want to run something that still contains compilation errors; most users don't read those warnings and blindly continue, hoping for the best; they come here afterwards with the most mysterious problems ;-)
kind regards,
Jos
package ducat;
// to check whether this set is unique or not.
public class UniqueSet {
public static void main(String s[]) {
int i,j,x=0,y=0;
boolean z=false;
for (i=0;i<s.length;i++)
{
x=Integer.parseInt (s[i]);
for (j=i+1;j<s.length;j++)
{ y=Integer.parseInt (s[j]);
if (x==y)
z=true;
break;
}
}
if (z==false)
System.out.println ("set is unique.");
else
System.out.println ("set is not unique.");
}
}
this is the code.
not only this my all codes are facing the same problem. even i have executed them successfully before. but now i'm unable to do the same.
yes.
in eclipse it is always used automatically i think.
plz tell me how to set class path in eclipse...?
You can set a classpath in Eclipse as follows: go to Run > Run Configuration ... select a configuration and select its classpath tab; but I wonder why you should need it because it is all set by Eclipse for you. Especially nothing needs to be done when you want to run an ordinary Java application.
kind regards,
Jos