0
0
Javaprogramming~15 mins

Command line execution in Java - Mini Project: Build & Apply

Choose your learning style9 modes available
Command Line Execution in Java
📖 Scenario: You are creating a simple Java program that prints a greeting message. You will write the code step-by-step and then run it from the command line.
🎯 Goal: Build a Java program named HelloWorld that prints Hello, Java! to the console. Learn how to write the code, compile it, and run it using the command line.
📋 What You'll Learn
Create a Java class named HelloWorld
Add a main method to the class
Print the exact text Hello, Java! to the console
Compile the Java program using javac HelloWorld.java
Run the compiled program using java HelloWorld
💡 Why This Matters
🌍 Real World
Java programs are often run from the command line during development and deployment.
💼 Career
Knowing how to compile and run Java code from the command line is essential for Java developers and software engineers.
Progress0 / 4 steps
1
Create the HelloWorld class
Write a public Java class named HelloWorld. Do not add anything else yet.
Java
Need a hint?

Start by typing public class HelloWorld { } exactly.

2
Add the main method
Inside the HelloWorld class, add a public static void main method with the exact signature public static void main(String[] args).
Java
Need a hint?

Remember the exact method signature: public static void main(String[] args).

3
Print the greeting message
Inside the main method, write a line to print Hello, Java! exactly using System.out.println.
Java
Need a hint?

Use System.out.println("Hello, Java!"); to print the message.

4
Run the program from the command line
After saving your file as HelloWorld.java, compile it by running javac HelloWorld.java in the command line. Then run the program with java HelloWorld. The output should be exactly Hello, Java!.
Java
Need a hint?

Use your terminal or command prompt to run these commands:
javac HelloWorld.java
java HelloWorld