# I can't execute a java file from the command prompt.



## truckiewow (Apr 13, 2010)

I have windows 7, the 64. Whenever I try to use 'java [class name]' in the command prompt, it returns 'Exception in thread "main" java.lang.NoClassDefFoundError: [class name]' The 'javac [class name].java' works fine, and creates the [class name].class file, but the java just won't work. Can anyone help me with this? Thanks


----------



## servalsoft (Apr 14, 2010)

If you can compile I assume you set up the path and env variables properly. Once you create your .class file, how are you trying to run it? because this exception sometime gets thrown if you try to run with "java <myApp.class>" the correct syntax is "java <myApp>" the name of the class, not of the file.
I hope this helps.


----------



## truckiewow (Apr 13, 2010)

I was typing it in as "java <myApp>", but I realized that I had to add the (I think it was the classpath that I changed) to include the specific folder that I had saved some classes and javas to. I can execute the classes that are in that specific folder, but not any other ones. I can type in "javac C:\....<myApp.java>", and it works fine, but I can't just type in the path for the java ("java C:\....<myApp>" doesn't work. Is there a way to make it to where I can just use "java <full path to my app here>", just like I can use "javac <(full path to my app here).java>"?

And thank you for helping me.


----------



## servalsoft (Apr 14, 2010)

Sounds like a path problem to me. People get that a lot when installing java. Can you please tell me your java version, where you installed java itself i.e C:\program files....., then show me ur set up of the environment variables for java. So that I can check that at least that is installed properly.


----------



## truckiewow (Apr 13, 2010)

I have the 1.6.0_19 version.
It's installed in (the java.exe is in this folder) : C:\Program Files\Java\jdk1.6.0_19\bin
The path variable is "C:\Program Files\Java\jdk1.6.0_19\bin; %CommonProgramFiles%\Microsoft Shared\Windows Live;"

And the classpath is "C:\Users\Michael\Documents\CIS3022\; .; C:\Program Files\Java\jre6\lib\ext\QTJava.zip"
The CIS3022 folder is where I have some of the java files and then their classes


----------

