John Schwartz John Schwartz - 5 months ago 9
Java Question

Unable to run java from CMD

I'm not sure what I'm doing wrong... I'm following several YouTube videos and I'm still unable to run my java program from the command prompt.

VERY first thing I did in cmd was:
set path="[copied URL to the JDK bin directory]"

Then I used 'cd' to get all the way to my homework directory, containing 4 java files.

Then I typed in 'javac' to compile it... (Let's just say it was hangman)

Finally, I typed in 'java hangman'

And it says: "Error: Could not find or load main class hangman" inside my cmd.

What have I done wrong?

(I'm using Windows 10 if this somehow makes a difference.)


Two things:

  1. Make sure your class name starts with capital letter, Hangman instead of hangman.
  2. Make sure you have public static void main(String[] args) method