15 Sep Create New Java Package in Eclipse
In the previous lessons, we learned how to create a new Project and Java Project in Eclipse. Now is the time to create new Java package. Packages in Java are a group of classes, interfaces and sub-package., which helps in controlling access. To create new Java package in Eclipse is quite easy. You can also create a package like the below,
Package statement is the first line visible in the source file,
For creating a Java package, you need to follow the below steps.
Launce Eclipse and go to the File Menu, then
File > New > Package
Now, a dialog box opens up, where you need to fill the source folder of package and the package name.
Add the details and work on the below option.
Here are some of the options provided by the New Java Package wizard in Eclipse,
Select where the new package gets saved. The default visible is the source folder, selected when the wizard started.
Here comes the name of the new package you want to add.
A separate file package-info.java is to be created or not. It has the package level documentation and annotations.
Demo Java Package in Eclipse
For demo, we will be creating a Java package. Go to File > New > Package and fill the details for the new Java package,
The name of our project is StudyopediaProject, which we created before.
We added a new package in it,
After clicking Finish above, the package gets created successfully as shown below,
We have till now created project and package name in Eclipse. The project name is StudyopediaApplication and the package is com.studyopedia. In the next lesson, we will learn how to create a new Java class and add it to the same package and project.