Java - Create a simple Java app in Linux on the command line

by
Jeremy Canfield |
Updated: June 20 2024
| Java articles
Create a .java file.
touch foo.java
Add the following markup to the .java file. Since the name of the file is foo.java in this example the name of the class is also "foo".
public class foo {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Compile the app. This will create a new file named foo.class.
javac foo.java
Execute foo and "Hello World" should be displayed.
~]# java foo
Hello World
Did you find this article helpful?
If so, consider buying me a coffee over at