Create a Simple Program in Java

To start coding in Java, make sure you have the Java Development Kit (JDK) and a Java Integrated Development Environment (IDE) like Eclipse or NetBeans installed on your computer. If not, please install them first.

Once you have Java and Eclipse IDE installed on your computer, follow these steps:

Open Eclipse

Launch Eclipse by double-clicking on the Eclipse icon or run the application from the installed location. Choose a workspace (a directory where your projects will be stored), and then click on the Launch button.

Create a New Java Project

  • Go to File > New > Java Project.
  • Enter a name for your project (e.g., MyFirstJavaProject) and click Finish.

Create a New Java Class

  • Right-click on the src folder within your new project.
  • Go to New > Class.
  • Enter a name for your class (e.g., Main) and check the box that says "public static void main(String[] args)".
  • Click Finish.

Write your Java Code

 Inside the Main.java file, Eclipse should automatically generate a template for your class. Modify it to look like this:

public class Main {

   public static void main(String[] args) {
     System.out.println("Hello, World!");
   }

}

Run your Java Program

Right-click anywhere inside the Main.java file. Select Run As > Java Application.

You should see the output "Hello, World!" printed in the Eclipse console.

Congratulations! You have successfully created and run a simple Java program in Eclipse. Feel free to modify and experiment with the code to further explore the Java programming language.