However I have been plagued with error after error while trying to get it to compile and run in my command prompt.
This is the latest, and most puzzling problem I've ran into yet:
I created a "Hi There!" program using Windows notepad:
package hiThere;
public class HiThere {
public static void main(String[] args) {
System.out.println("Hi There");
}
}
Simple. It's created on my desktop in:
C:\Users\Achri\Desktop\hiThere
//my cmd prompt
C:\Users\Achri\Desktop\hiThere>javac HiThere.java
C:\Users\Achri\Desktop\hiThere>
C:\Users\Achri\Desktop\hiThere>java HiThere
Exception in thread "main" java.lang.NoClassDefFoundError: HiThere (wrong name:
hiThere/HiThere)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
2)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:476)
C:\Users\Achri\Desktop\hiThere>
I've spent some time searching and I think the problem is my CLASSPATH variable.
because when I go up a level:
C:\Users\Achri\Desktop\hiThere>cd.. C:\Users\Achri\Desktop>java hiThere.HiThere Hi There C:\Users\Achri\Desktop>
So I went in and I didn't even have a CLASSPATH variable in my environment variables (Windows 7).
I added a variable named CLASSPATH with a Value of .;
So now when I perform an echo %CLASSPATH%, I receive .; instead of %CLASSPATH%.
Now when I go back into C:\Users\Achri\Desktop\hiThere I still see the same error? Is adding .; as CLASSPATH, not doing what I was expecting? (I was expecting it to let me run my files from the folder they are sitting in)

New Topic/Question
Reply




MultiQuote




|