2 Answers - Sort by: Date | Rating
Packages provide an easy way for name space management. In the packages related classes and interfaces are grouped together. The classes and interfaces that provide similar functionality are packaged into one group. Every time when a package is created a new name space is created. Classes defined in a package at the same level can access the members of other classes. Packages can also be nested in other packages. Following are steps of creating and using the packages in java:
Packages are to be declared before they can be used. The following statement is written at the start of every source file that is to be included in the package.package package_name;
Package declaration contains the keyword 'package' followed by the package name.All the source files are then placed in the directory whose name is the same as that of the package.
Compile the source files to produce the class files for each type defined in the source code. You can place the .java files any where however the class files must be in a directory whose name is the same as that of the package.Then set the classpath variable as followsjavac –classpath "d\javasourcefiles\mypackage" mytype.java.Here "d\javasourcefiles\mypackage" is the path of the package and mytype.java is the source file.o use the classes defined in a package you need to import the specific class or the package in your program using the import statement like the one as follows:mport java.awt.*;This statement allows you to use all the types defined in the package awt.
Packages are to be declared before they can be used. The following statement is written at the start of every source file that is to be included in the package.package package_name;
Package declaration contains the keyword 'package' followed by the package name.All the source files are then placed in the directory whose name is the same as that of the package.
Compile the source files to produce the class files for each type defined in the source code. You can place the .java files any where however the class files must be in a directory whose name is the same as that of the package.Then set the classpath variable as followsjavac –classpath "d\javasourcefiles\mypackage" mytype.java.Here "d\javasourcefiles\mypackage" is the path of the package and mytype.java is the source file.o use the classes defined in a package you need to import the specific class or the package in your program using the import statement like the one as follows:mport java.awt.*;This statement allows you to use all the types defined in the package awt.
0
0
- A Java Program To Get Sports Marks In Student Package And Print Total Marks Of Student?
- The Project Aims To Implement A JAVA Parser? 1- Classes And Functions 2- Arithmetic/logic Expressions 3- If Statement
- How To Get Java On My Lg 260?
- Write A Java Program To Store A Number Find If It Is Positive Or A Negative Number If Positive Print I Am The First?
- How To Update The Sim 3 Expansion?
- What Is An Attribute In Java?
- Do I Have To Write A Main Method In Every Class I Create?
- What How The Step For Make Library Management?
- In Which Process We Can Start Java?
- Define The Concept Of Java Byte Code?
- How To Run Remote Method Invocation In More Machine?
- How To Run Java Remote Method Invocation In More Machine?
- How To Make A Java Program That Will Ask The User To Input A Number And Display All The Even Number And The Sum Of All Even Numbers Based On The Inputted/ Given Numbers?
- Is A Static Variable An Instance?
- How To Compile And Run Java Package?
- What Does Literati-on Mean?
- What Is Abstract Class In Details?
- What Is Meant By Remote Method Invocation In Java?
- What Is Meant By Servlet In Java?
- What Is Latest Technologies In Java?
- Write A Program Using Do…..while Loop To Calculate And Print The First M Fibonacci Numbers?
- What Is The Difference Between Reference &instance Variable?
- Why Java Is Slow?
- What Is The Drawback Of Ms Access?
- What Is Replaced In Place Of Pointers In Java?

New Comment - Comments are editable for 5 min.