Linux Apps Tutorials - Herong's Tutorial Examples - v1.03, by Herong Yang
First Java Program - Hello.java
This section provides a tutorial example on how to write, compile, and execute the first Java program, Hello.java, with OpenJDK.
With OpenJDK's JRE and JDK packages installed, we can use "javac" and "java" commands to compile and run Java programs.
Let's try these commands with a very simple Java program. Use a text editor to enter the following Java program into a file called Hello.java:
class Hello { public static void main(String[] a) { System.out.println("Hello world!"); } }
Then compile this program with the "javac" command:
herong$ javac Hello.java
To execute the program, use the "java" command:
herong$ java Hello Hello world!
Congratulations, you have successfully entered, compiled and executed your first Java program.
Table of Contents
Running Apache HTTP Server (httpd) on Linux Systems
Running Apache Tomcat on Linux Systems
Running PHP Scripts on Linux Systems
Running MySQL Database Server on Linux Systems
Running Python Scripts on Linux Systems
Conda - Environment and Package Manager
Install and Manage OpenJDK on CentOS
►First Java Program - Hello.java