0% found this document useful (0 votes)
29 views1 page

Detaild Steps To Create Package

To create a package in Java: 1. Create a folder with the same name as the package and save a Java program file within it. 2. The first line of the Java program file must declare the package name, which should match the folder name. 3. Compile the program, ensuring the package folder is in the classpath if not in the same directory as the main program file.

Uploaded by

Govind Upadhyay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views1 page

Detaild Steps To Create Package

To create a package in Java: 1. Create a folder with the same name as the package and save a Java program file within it. 2. The first line of the Java program file must declare the package name, which should match the folder name. 3. Compile the program, ensuring the package folder is in the classpath if not in the same directory as the main program file.

Uploaded by

Govind Upadhyay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Detaild steps to create package

1. Create a folder with a suitable name which will be the name of your package (suppose
mypackage)
2. Now write a program (suppose myclass.java) in your java editor (i.e. notepad) and
save it in your above created folder (mypackage)
3. Write a statement in your above program file (myclass.java) which must be first line
in your above program which is given as:
package your_folder_name;
4. NOTE: your package name and folder or directory name must be same
5. Now compile your program using javac compiler
6. If your package and your program file are in same directory (i.e. are sibling)
a. Import your package and use it
7. If your package and your program file are at\in different locations\folders then
a. Set class path using the following command :set classpath = .;path of your package;
b. Import your package and use it

You might also like