In this article we want to learn how to Create First Hello World Java Program, “Hello World” program is a classic way for developers to get started with new programming language. it involves creating simple program that outputs the text Hello World to the screen. in this tutorial we want to talk about creating your first Hello World program in Java.
Create First Hello World Java Program
Before you can start coding in Java, you need to set up your development environment. two main components you need are Java Development Kit (JDK) and an Integrated Development Environment (IDE). JDK provides the tools and libraries needed to write and run Java programs. you can download the latest version of the JDK from the Oracle website. IDE is software application that provides an integrated environment for writing, testing and debugging code. there are many different IDEs available for Java development, including Eclipse, IntelliJ IDEA and NetBeans.
Create Java Project
Once you have your development environment set up, you can create new Java project. open your IDE and select New Project from the File menu. choose Java Project and give your project a name.
Create new Java class
In Java class is a blueprint for creating objects. to create your Hello World program, you need to create a new class. in your IDE, select New Class from the File menu. give your class a name for example we call it HelloWorld and click on Create.
Now that we have a new class, you can start writing your code. in Java every program must have main method, which is the entry point for the program. to create main method add the following code to your HelloWorld class.
1 2 3 4 5 6 7 8 |
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } } |
This code defines a class called HelloWorld and main method that outputs the text Hello world to the console.
If you run the code this will be the result
Learn More