There five steps to create and run your code.

  1. create a Java project
  2. create a Java package
  3. create a Java class in the package
  4. setup a run configuration
  5. run your code

As mentioned before, the fact that Eclipse doesn’t require you to compile your code can be confusing to new comers, particularly if you’ve use tool that require you to compile and link you code before you run or debug it.

How to creating a Java project

  • Start with File<>New<> Project…
  • Choose Java Project, give it a name and click Finish

If you want to work with Java code, you start by creating a Java project. You’ll put your packages,

classes and interfaces inside the project.

  • After naming the project, other options will appear
  • These options will allow you to set the class path of your project

Typically, you enter a name for the Java project and click Finish. If you can click Next instead and add JAR files to your project, references to other projects or set up similar options.

How creating a Java package

  • To create a Java package, right-click on your new project in the Package Explore, then choose New->Package…

If you don’t see these menu items when creating a package, make sure you’re the Java perspective.

  • Enter a name for the package
  • Eclipse will remind you if you if you break a Java style rule

An example would be if your package begins with an uppercase letter.

The new package appears in the Package Explorer beneath the project.

When you create your new Java package Explorer. Be aware that as you change perspective, your projects and packages may disappear or be disappear or be displayed in different ways. Don’t worry —all your files are still there. Whenever you switch back to the Java perspective, you’ll see the same views you see here.

How Create a Java Class

  • To create a Java class, right-click on the new package in the Package Explorer, then choose New->Class

If you look at the menus, you’ll see that you create new interfaces, Enums and Annotations the Same way.

  • Enter a name for the class
  • Eclipse reminds you of style rules here as well
  • You can set the details of the class, including its surperclasses, visibility and interfaces.

You can use content assist for the names of superclasses and interfaces as you new Java class. as well; if you’ve created an interface name com.dougco.Mailbox, content assist will suggest it as a completion for mail.

  • The new class appears in the Package Explorer beneath your package
  • Eclipse also opens the  source file for the class in the Java editor

The source of the new Java class is generated and opened in the Java editor. Some comments will be generated automatically; you can use Window – Preferences to define what comments ypu would like added to classes, interfaces and methods when you create them.


  • You can create a new package and a new class at the same time
  • Simply create a new  class and enter a new package name in the wizard

You can create a new package when you create a class.




Leave a Reply

Your email address will not be published. Required fields are marked *