Results 1 to 9 of 9
  1. #1
    Army is offline Senior Member
    Join Date
    Jan 2012
    Posts
    147
    Rep Power
    0

    Default Using the CMD error



    I keep getting that error but I see the freaking file on my desktop, the thing must be blind.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,450
    Blog Entries
    7
    Rep Power
    20

    Default Re: Using the CMD error

    Remove the '.class' suffix when you try to run your class file.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Army is offline Senior Member
    Join Date
    Jan 2012
    Posts
    147
    Rep Power
    0

    Default Re: Using the CMD error

    I did it without the .class suffix the first time.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,450
    Blog Entries
    7
    Rep Power
    20

    Default Re: Using the CMD error

    Show us the source code for that class; in general you have to do this:

    Java Code:
    javac YourClass.java
    java YourClass
    If your class lives in a package you have to mention the package name as well if you want to run it.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Army is offline Senior Member
    Join Date
    Jan 2012
    Posts
    147
    Rep Power
    0

    Default Re: Using the CMD error



  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,450
    Blog Entries
    7
    Rep Power
    20

    Default Re: Using the CMD error

    Just a guess: can you try the same outside of that Desktop directory? If that fails as well, please show the source code for your HelloWorld class (i.e. the .java file).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Using the CMD error

    You could also try

    Java Code:
    C:\Users\Lenovo\Desktop>javac -cp . HelloWorld.java
    C:\Users\Lenovo\Desktop>java -cp . HelloWorld
    If you have a CLASSPATH variable set it will override the default behaviour (look for classes in the current directory) unless you explicitly use dash-c-p-space-dot. Unless other software is using it, you should remove the CLASSPATH environment variable.

  8. #8
    Army is offline Senior Member
    Join Date
    Jan 2012
    Posts
    147
    Rep Power
    0

    Default Re: Using the CMD error

    Quote Originally Posted by pbrockway2 View Post
    You could also try

    Java Code:
    C:\Users\Lenovo\Desktop>javac -cp . HelloWorld.java
    C:\Users\Lenovo\Desktop>java -cp . HelloWorld
    If you have a CLASSPATH variable set it will override the default behaviour (look for classes in the current directory) unless you explicitly use dash-c-p-space-dot. Unless other software is using it, you should remove the CLASSPATH environment variable.
    THANKS that WORKED!

  9. #9
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

Similar Threads

  1. java out of memory error-heap space error
    By elsanthosh in forum NetBeans
    Replies: 4
    Last Post: 06-15-2010, 09:31 AM
  2. Replies: 1
    Last Post: 03-10-2010, 01:53 PM
  3. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  4. Replies: 1
    Last Post: 10-26-2009, 04:38 PM
  5. Replies: 3
    Last Post: 01-23-2009, 08:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •