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

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

truckiewow

Thread Starter
Joined
Apr 13, 2010
Messages
3
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
 
Joined
Apr 14, 2010
Messages
6
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

Thread Starter
Joined
Apr 13, 2010
Messages
3
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.
 
Joined
Apr 14, 2010
Messages
6
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

Thread Starter
Joined
Apr 13, 2010
Messages
3
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
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top