Eclipse Creating Java Package



Once we create a Java Project in Eclipse, we might want to create a java package in Eclipse IDE. It can be achieved using the three ways –

Eclipse Creating Java Package

We can create the Java Project using the following 3 different ways –

  1. By clicking on the File menu and choosing New > Package
  2. By right clicking anywhere in the Project Explorer and selecting New > Package
  3. By clicking on the New button (Select Java Package ) in the Tool bar and selecting Package

Steps to create Package

Right click on the package explorer in the Eclipse Workspace and then select the package option

Creating Java Package in Eclipse

Once you select the package option then you will be prompted with the below screen

Eclipse Naming Java Package

You need to name your Java package which should not contain the space or dot at the last. Otherwise it will provide you following error message – Invalid package name. A package name cannot start or end with a dot

Invalid Java Package Name

Once we create package then we can see it inside the package explorer like this –

Eclipse Viewing Package