Step-by-Step Guide to Java Project in Eclipse

Feb 16, 2025

Creating a New Java Project in Eclipse

Steps to Create a Java Project

  1. Navigate to File Menu

    • Select File > New > Java Project.
  2. Enter Project Name

    • In the pop-up window, provide a project name (e.g., MyFirstJavaApp).
    • Click Next.
  3. Adjust Project Settings

    • Uncheck the box for Create module-info.java.
    • Click Finish to generate the new Java project.
  4. Open Package Explorer

    • Click on the two windows icon in the top left to open the Package Explorer.
    • Locate your Java project here.
  5. Create a Source Folder

    • Expand the project to view the src (source) folder.
    • This folder will contain all Java classes.

Adding a New Class

  1. Create a New Class

    • Right-click on the src folder.
    • Select New > Class.
    • Enter a class name (e.g., Main).
      • Note: Java class names should start with an uppercase letter.
  2. Main Method

    • Check the box for public static void main to generate the main method (entry point).
    • Click Finish to complete.

Writing the Main Method

  • Output a Message
    • Add the statement System.out.println("Hello World"); inside the main method.
    • This will print "Hello World" to the console.

Running the Java Application

  1. Run the Application

    • Right-click on Main class.
    • Select Run As > Java Application.
  2. Console Output

    • The console will display the message "Hello World".

Conclusion

  • Successfully created and ran a simple Java application.
  • Congratulations on completing the setup of your first Java project!