On terminal/bash, first compile the program then run it:
javac hello.java
java hello
You should see 'Hello World' printed to your console.
- Copy and create
HelloWorld.java
- Download acm.jar and put it in the same folder as your java files.
javac -cp acm.jar HelloWorld.java
java -cp acm.jar: HelloWorld
You should see a GUI coming out and prints 'Hello World' there.
These steps may or may not work in other environment, due to the variances in command line syntax of the java compiler/interpreter.
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
If you have compile error: https://stackoverflow.com/questions/5012125/javac-no-source-files-found