How to Compile a Java program in Eclipse

Step 1:

When you start eclipse, it asks your for the address of the workspace. Workspace is a folder where eclipse will store all your project files.
enter the address of the workspace

Step 2:

To start a new project go to New->JAVA project.
Start a new project

Step 3:
Enter the details of your project i.e your project name.

Enter your project name

Step 4:

Create a new class. To do this right click on your project name which is “MyProject” in this case and select New->Class.

Creating a new class

Step 5:

Enter the name of your class. Click finish.

Enter name of the class

Step 6: Compiling

To compile, just press the RUN button or the DEBUG button to the left of the run button.


The following two tabs change content below.
  • Lynne Toh

    Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me.

  • admin

    Hey Lynne, we’re glad you found our website helpful and yes we are constantly adding new information everyday. However, if you have any program request or any other request you can always ask us via comments.

  • pandezzzy

    thnx guyz!!!!

  • Shane

    What about how to just compile and not run…

    • Vlad

      Just press the compile button at the side of the Run button. :)

  • Reem

    When I run it as a java application it gives an error message saying the application does not contain a main type, and as an applet it says the selection does not contain an applet??

    • doak

      Hi Reem, try giving us more info with the error and maybe also with what you’re trying to do.

      The method above is quite general and should work similarly for almost all IDEs.

      Make sure your program does not have syntax or case errors.
      eg. make sure your main() function is ‘main’ and not ‘Main’

  • vipin

    thanks alot

  • Rick


    I’m fairly new to Java and had some difficulties running the application.

    1. The projects im using are from another Java tool called Bluej
    2. I wanted to run these project in eclipse instead so I imported them
    3. The problem is that whenever I want to run the application, the console always remains blank. I declared the main method (public static main void etc..) but still cannot get the console to display anything.
    4. Iv used Eclipse both galileo & heliosis
    5. Iv also installed the latest java (7)

    The project works in Blue J with no problem but I would like to practice them in Eclipse instead.

    Many Thanks :)


    edit: I just tried doing a simple system.out.println in eclipse (class created in eclipse) give me the same result as the project class :(

  • Vlad

    Rick, does eclipse encounter any errors while compiling your program?
    Secondly, try running the program in command prompt if it works there.
    Also try creating a new fresh project in Eclipse just to check if anything is wrong with your eclipse.

    Hope it helps.

  • Vik


    please help .. when i am running the program nothing was showing in eclips . What could i do?


  • mira

    how can I run the commant in eclipse using samsung smart tv sdk?