0 votes
in JAVA by
How to create packages in Java?

1 Answer

0 votes
by

If you are using the programming IDEs like Eclipse, NetBeans, MyEclipse, etc. click on file->new->project and eclipse will ask you to enter the name of the package. It will create the project package containing various directories such as src, etc. If you are using an editor like notepad for java programming, use the following steps to create the package.

Define a package package_name. Create the class with the name class_name and save this file with your_class_name.java.

Now compile the file by running the following command on the terminal.

javac -d . your_class_name.java  

The above command creates the package with the name package_name in the present working directory.

Now, run the class file by using the absolute class file name, like following.

java package_name.class_name  

Related questions

+1 vote
asked May 31, 2020 in NodeJS Essentials by Robindeniel
+2 votes
asked May 13, 2021 in JAVA by rajeshsharma
...