L
lonelyplanet999
Hi,
I have below .java files:
c:\javapgm\Level1.java
File content:
package l1;
public class Level1 {
public static void main (String[] args) {
System.out.println("Level 1");
}
}
Compilation passed without error with above code. However, as I ran
the program, below run time error was output.
Exception in thread "main" java.lang.NoClassDefFoundError: Level1
(wrong name: l1/Level1)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.lang.security.SecureClassLoader.defineClass(SecureClassLoader.java:12)
..... skippped details.
After I commented out the statement package l1;, the program ran
without error.
Previously I have written a program Aclass3.java, the program also
passed compilation but failed in runtime with similar problem. The
problem got solved after I commented the package Aclass3.java;
statement at Aclass3.java.
I would like to ask why the simple package statement will cause the
program execution failed.
http://www.google.com.hk/groups?hl=...10200755.394c9fa8%40posting.google.com&rnum=1
I have below .java files:
c:\javapgm\Level1.java
File content:
package l1;
public class Level1 {
public static void main (String[] args) {
System.out.println("Level 1");
}
}
Compilation passed without error with above code. However, as I ran
the program, below run time error was output.
Exception in thread "main" java.lang.NoClassDefFoundError: Level1
(wrong name: l1/Level1)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.lang.security.SecureClassLoader.defineClass(SecureClassLoader.java:12)
..... skippped details.
After I commented out the statement package l1;, the program ran
without error.
Previously I have written a program Aclass3.java, the program also
passed compilation but failed in runtime with similar problem. The
problem got solved after I commented the package Aclass3.java;
statement at Aclass3.java.
I would like to ask why the simple package statement will cause the
program execution failed.
http://www.google.com.hk/groups?hl=...10200755.394c9fa8%40posting.google.com&rnum=1