I am currently trying to run my first java script:
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } }
I decided to take a look at Java. However, I come from languages ββlike JavaScript and PHP that do not require compilation or something like that.
So far, I think Iβm compiling it correctly on the command line:
C:\Users\Shawn>"C:\Program Files\Java\jdk1.7.0_25\bin\javac.exe" "HelloWorld.java"
It adds a file called: HelloWorld.class , so I did something right.
However, now when I try to run the program using:
C:\Users\Shawn>"C:\Program Files\Java\jdk1.7.0_25\bin\java.exe" "C:\Users\Shawn\HelloWorld.class"
I get this, Error: Could not find or load main class C:\Users\Shawn\HelloWorld.class .
However, if I try the same command but use javac.exe , instead I get:
javac: invalid flag: C:\Users\Shawn\HelloWorld.class Usage: javac <options> <source files> use -help for a list of possible options
Why is this happening? Why is my program not running correctly?
source share