compile and run

suppose i have created my file in "C:\Program Files\IBM\jprog" named primary.java. now i compile it on Dos prompt giving command c:\>javac "program files\ibm\jprog\primarya.java". then compilation is ok class file is also created. but when i tried to run it from c:\>java "program files\ibm\jprog\primary" and c:\program files>java ibm\jprog\primary it is not running and giving C:\>java "program files\ibm\jprog\primary" Exception in thread "main" java.lang.NoClassDefFoundError: program files\ibm\jpr og\primary (wrong name: primary) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12 4) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

Sweety, When you are using javac there is .java at end which DOS can see as a file and so it works out, but while you run it you don't give .java extension to your file so its considering it as a dir name itself. You can try this to run it-:

C:\>java -cp "program files\ibm\jprog" primary

Check it out

Note- Here cp stands for classpath, you can check what all option you can use by simply giving java and javac commands in DOS.