classpath - packaging problem
Hi all, I spent all day today trying to figure this out but no luck so far, maybe a keen eye can see better than me.
I am learning about packagin and I have a program that I am trying to run and I get the infamous error COULD NOT FIND THE MAIN CLASS
this is the code :
package ch4.access;
class WithProtected {
protected int i;
}
public class E06_ProtectedManipulation {
public static void main(String args[]) {
WithProtected wp = new WithProtected();
wp.i = 47;
System.out.println("wp.i = " + wp.i);
}
}
and this is the error :
d:\JavaProjects\TIJ4\ch4\access>javac E06_ProtectedManipulation.java
d:\JavaProjects\TIJ4\ch4\access>java E06_ProtectedManipulation
Exception in thread "main" java.lang.NoClassDefFoundError: E06_ProtectedManipu
tion (wrong name: ch4/access/E06_ProtectedManipulation)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknow n Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: E06_ProtectedManipulation. Program will exit.
PS: the file is in here D:\JavaProjects\TIJ4\ch4\access\E06_ProtectedManip ulation.java
CLASSPATH is set to :
.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip; d:\JavaProjects\TIJ4
Running Windows 7 Professional 64 bit
Any help would be greatly appreciated :frusty: