Main Menu

search

You are here

Java: test with 'Hello World'

[last updated: 2019-05-23]
go to: Java: download & install on Linux
-----

After successful installation, as evidenced by $ java -version,
and after editing /etc/profile to add system variables,

  • use text editor to write a Java program:
    class A {
        public static void main(String args[]) {
            System.out.println("Hello World");
        }
    }
  • save the file/program as (eg.) myProg.java
  • Then compile it:
    $ javac myProg.java
  • This creates a file named "A.class", the "A" being the name of the class that you've defined in your program.
  • Then this file is executed with:
    $ java A

.

.

.

eof