Here’s the prototypical first Java application — HelloWorld.java:
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
That’s about as small as a Java application gets!
Compile it:
javac HelloWorld.java
which produces a HelloWorld.class file.
Then execute it:
java HelloWorld
Note: We’re executing the class, not the file!
It should output:
Hello World!!
followed by a newline.
Note: In the real world, the actual command line contents are more complex than this. IDEs simplify things by doing all the nitty-gritty nasty stuff under the covers.
