1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

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

Discussion in 'Software Development' started by truckiewow, Apr 13, 2010.

Thread Status:
Not open for further replies.
Advertisement
  1. truckiewow

    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
     
  2. servalsoft

    servalsoft

    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.
     
  3. truckiewow

    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.
     
  4. servalsoft

    servalsoft

    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.
     
  5. truckiewow

    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
     
  6. Sponsor

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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/916683