I wrote a simple test.java program in vi. I know it compiles correctly because I went into the directory where test.java was and compiled it and it created a java.class. I then ran test.java by staying in the same directory where it was and it worked great.
However, when i backed out of the directory to the home directory I typed the following and it did not run test.java. Why not? I specified the path in the most direct way possible.
(shaneyost@Shanes-MacBook-Pro-2:s000)(~)
(1:19:31:%) java ./java_programs/test_program/test.java (Tue, 20130730)
Exception in thread "main" java.lang.NoClassDefFoundError: //java_programs/test_program/test/java
Caused by: java.lang.ClassNotFoundException: ..java_programs.test_program.test.java
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
This was when I was in the directory where test.java and test.class was. It worked.
(shaneyost@Shanes-MacBook-Pro-2:s000)(~/java_programs/test_program)
(19:29:%) java test (Tue, 20130730)