How to Create and Run a Java Project in Eclipse

  1. Create a new Java Project

    Go to File -> Java Project

  2.  

    Give your Project a Name and Click on Finish

 

 

 

2) Create new Java Classes (All Class Names are Capitalized)

Right Click on your new project name and click on Class

 

Enter a Class Name - Begin with a Capital Letter, and for now Do NOT put in a Package Name. Click on Finish

You can add your code to the Class.

To Run a Java application right click on the Project Name and pick RUN AS -> Java Application, To run an Applet pick RUN AS-> Java Applet

Enter the following Code

import java.lang.*; // import Statement - these are predefined java api libraries that supply functionality.

public class HelloWorld { // Class Definition - class name is HelloWorld and its scope is public

    public static void main(String [] args){ //Declares the main method - main() runs your program & takes in an array of command line Strings as arguments

    System.out.println("Hello World"); // Writes to a String System.out

    }

}

Run As a Java Application - Congratulations you have run your first Java program