This code compiles but does not run: NoClassDefFoundError
Exact error message:
C:\jdk1.3\bin>java Sum
Exception in thread "main"
java.lang.NoClassDefFoundError : Sum
Am i getting this because i have multiple jdk's
on my computer and that messed up the claspathing?
the Sum file is in the bin dir:
here the file:
//////////////////////////////////////////////////
// this code compiles but it does not run
// the error message i get is java Sum Exception in
// Thread "main" java.lang.NoClassDefFoundError: Sum
// i compile it in the dir D:\jdk.13\bin>
// do i need to set the classpath?
// my email is
corradino@collegeclub.com import javax.swing.JOptionPane;
public class Sum extends Object {
public static void main( String args[] )
{
int sum =0;
for ( int number =1; number <=100; number++)<br /> sum +=number;<br /> <br /> JOptionPane.showMessageDialog( null, " the sum is " + sum,<br /> "Sum integers from 1 to 100",<br /> JOptionPane.INFORMATION_MESSAGE );<br /> System.exit( 0 );<br /> }<br /> }<br /> /////////////////////////////////////////////////////<br /> <br /> I also tried C:\>c:jdk.13\bin\javac -classpath "
C:\jdk1.3\bin;" Sum.java
PS: this error never happened until i installed multiple
jdks and i also uninstalled all of them and reinstalled
jdk1.3 and i still get the same error!