Writing and Running the first Java Program
Once a Java developer has installed, configured, or installed the Java Development Kit (JDK) and an Eclipse, IntelliJ IDEA, or NetBeans Java IDE software on their computer, Java user programmers can now create their first Java program. Here, we’ll create a simple Java program that prints a “Welcome to Java programming!” text message to the user console screen.

Here’s a step-by-step guide to creating and running a “Welcome to Java programming!” program in Eclipse, IntelliJ IDEA, and NetBeans Java IDEs software.
Creating and running “Welcome to Java programming!” in the Eclipse Java IDE.
Step 1 – First, create a new Java project.
Open the Eclipse Java IDE software.
From the File menu, select New > Java Project.
Provide a name for your first Java project, e.g., welcome msg, and click the Finish option.
Step 2 – Create a new Java class.
Now in the Project Explorer on the left, right-click the src folder inside your new Java project and select New > Class.
In the “New Java Class” dialog window,
insert welcome msg as the class name.
Check the box for public static void main(String[] args) to add the Java main class method.
and click the Finish option.
Step 3 – Create the Java welcome message program code.
In Eclipse, open a new editor tab for the welcome msg.java class.
Inside the welcome msg class, you will see the default Java program structure displayed.
public class welcome msg {
public static void main(String[] args) {
// Write your Java program source code here
}
}
Inside the main Java class method, the console screen will display “Welcome to Java programming!” Add this code to your program to print a text message.
public class welcome msg {
public static void main(String[] args) {
// Let print “Welcome to Java programming!” to the console screen.
System.out.println(“Welcome to Java programming!”);
}
}
Step 4 – Run your Java program.
To run your Java program, click the green Play button at the top of the Eclipse Java IDE window, or right-click the welcome msg.java file in Project Explorer and select Run As > Java Application.
Java users should see this message displayed as output in the console window.
Welcome to Java programming!
Creating and running the “Welcome to Java programming!” program in IntelliJ IDEA.
Step 1 – Create a new Java project.
Open the IntelliJ IDEA Java IDE installed on your computer.
From the IntelliJ IDEA Welcome screen, click the Create New Project option.
In the New Project dialog, select Java from the options and select the appropriate Java JDK version.
Click the Next option and provide a name for your project. For example, welcome msg.
Click the Finish option.
Step 2 – Create a new Java class.
In the Projects window on the left in IntelliJ IDEA, right-click the src folder and select New > Java Class.
Name your Java program class welcome msg and click the OK option.
Step 3 – Write your first Java program source code.
Your new class welcome msg.java will open. In the editor window, add your Java welcome msg code.
public class welcome msg {
public static void main(String[] args) {
// let Print Welcome to Java programming! to the console screen
System.out.println(“Welcome to Java programming!”);
}
}
Step 4 – Run your Java program.
To run your Java program, click the green Play button in the top-right corner of IntelliJ IDEA or right-click the welcome msg.java file and select the ‘welcome msg’ run option.
This output will display in your IntelliJ IDEA Run window.
Welcome to Java programming!
Creating and running “Welcome to Java programming!” in the NetBeans Java IDE.
Step 1 – Create your new Java project.
Open the NetBeans Java IDE application installed on your computer.
Select a new project from the File menu.
In the New Project dialog, select Java > Java Application and click the Next option.
Provide a name for your project, e.g., welcome msg, and click the Finish option.
Step 2 – Create a new Java class.
In the NetBeans Java IDE, expand the Source Packages folder in the Projects window on the left, right-click the default package or src, and select New > Java Class.
Provide a welcome message to your Java class and click the Finish option.
Step 3 – Create your Java program code.
A new welcome msg.java file will open in the NetBeans Java IDE editor window. Add your welcome msg Java program source code to the Java main method.
public class welcome msg {
public static void main(String[] args) {
// let print Welcome to Java programming! to the console screen
System.out.println(“Welcome to Java programming!”);
}
}
Step 4 – Run your Java program.
To run the NetBeans Java program, click the green Play button in the Toolbar tab or right-click the project name in the Projects window and select the Run option.
You should now see this message displayed in the output window at the bottom.
Welcome to Java programming!
Detailed explanation of the Java welcome msg code.
Here is a detailed explanation of the welcome msg Java program.
public class welcome msg {
public static void main(String[] args) {
// Let print Welcome to Java programming! to the console screen
System.out.println(“Welcome to Java programming!”);
}
}
Detailed explanation of the above Java program.
- public class welcome msg – This statement declares and defines a public class named welcome msg in the Java program. Every Java application must have at least one such class. The class name must also properly match the file name welcome msg.java.
- public static void main(String[] args) – This is the main method in a Java program, which is the entry point of any Java application. When a Java programmer runs the program, the JVM starts execution from here. Here the String[] args parameter allows passing command-line arguments to the Java program, as such, it is not used in this example.
- System.out.println(“Welcome to Java programming!”); – This Java console statement prints the text message “Welcome to Java programming!” to the console. Here System.out is a built-in Program class object for output, and println is a text message statement method that prints a new text line or statement in the program after a message.
