SlideShare a Scribd company logo
1 of 11
Packages In Java
Packages
• Packages enable grouping of functionally related
classes
• Package names are dot separated, e.g., java.lang.
• Package names have a correspondence with the
directory structure
• Packages Avoid name space collision. There can not
be two classes with same name in a same Package
But two packages can have a class with same name.
• Exact Name of the class is identifed by its package
structure. << Fully Qualified Name>>
java.lang.String ; java.util.Arrays;
java.io.BufferedReader ; java.util.Date
How To Create a Package
• Packages are mirrored through directory
structure.
• To create a package, First we have to create
a directory /directory structure that matches
the package hierarchy.
• Package structure should match the
directory structure also.
• To make a class belongs to a particular
package include the package statement as
the first statement of source file.
Exercise Creating Packages
mypackage
mypackageBmypackageA
ABC DEG IJK XYZ
S1,S2,S3 S4,S5,S6
A,B,C D,E,F A,B,C,I,J,K X,Y,Z
Package ABC and IJK have classes with same name.
A class in ABC has name mypackage.mypackageA.ABC.A
A class in IJK has name mypackage.mypackageB.IJK.A
How to make a class Belong to a Package
• Include a proper package statement as first line in source file
Make class S1 belongs to mypackageA
package mypackage.mypackageA;
public class S1
{
public S1( )
{
System.out.println("This is Class S1");
}
} Name the source file as S1.java and
compile it and store the S1.class file in
mypackageA directory
Make class S2 belongs to mypackageA
package mypackage.mypackageA;
public class S2
{
public S2( )
{
System.out.println("This is Class S2");
}
}
Name the source file as S2.java and
compile it and store the S2.class file in
mypackageA directory
Make class A belongs to IJK
package mypackage.mypackageB.IJK;
public class A
{
public A( )
{
System.out.println("This is Class A in IJK");
}
}
Name the source file as A.java and compile
it and store the A.class file in IJK directory
<< Same Procedure For all classes>>
Importing the Package
• import statement allows the importing of package
• Library packages are automatically imported
irrespective of the location of compiling and executing
program
• JRE looks at two places for user created packages
(i) Under the current working directory
(ii) At the location specified by CLASSPATH
environment variable
• Most ideal location for compiling/executing a program
is immediately above the package structure.
Example importing
import mypackage.mypackageA.ABC;
import mypackage.mypackageA.ABC.*;
class packagetest
{
public static void main(String args[])
{
B b1 = new B();
C c1 = new C();
}
}
This is Class B
This is Class C
<< packagetest.java>>
<< Store it in location above the package
structure. Compile and Execute it from
there>>
import mypackage.mypackageA.ABC.*;
Import mypackage.mypackageB.IJK.*;
class packagetest
{
public static void main(String args[])
{
A a1 = new A();
}
}
<< What’s Wrong Here>>
<< class A is present in both the imported
packages ABC and IJK. So A has to be fully
qualified in this case>>
mypackage.mypackageA.ABC.A a1 = new mypackage.mypackageA.ABC.A();
OR
mypackage.mypackageB.IJK.A a1 = new mypackage.mypackageB.IJK.A();
CLASSPATH Environmental Variables
• CLASSPATH Environmental Variable lets you define
path for the location of the root of the package
hierarchy
• Consider the following statement :
package mypack;
What should be true in order for the
program to find mypack.
(i) Program should be executed from the location
immediately above mypack
OR
(ii) mypack should be listed in the set of directories
for CLASSPATH

More Related Content

What's hot (20)

Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Java program structure
Java program structure Java program structure
Java program structure
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
Package in Java
Package in JavaPackage in Java
Package in Java
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Java IO
Java IOJava IO
Java IO
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Java Streams
Java StreamsJava Streams
Java Streams
 
Java packages
Java packagesJava packages
Java packages
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Java program structure
Java program structureJava program structure
Java program structure
 
Java packages
Java packagesJava packages
Java packages
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
Packages,static,this keyword in java
Packages,static,this keyword in javaPackages,static,this keyword in java
Packages,static,this keyword in java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
java Features
java Featuresjava Features
java Features
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 

Viewers also liked

Packages and inbuilt classes of java
Packages and inbuilt classes of javaPackages and inbuilt classes of java
Packages and inbuilt classes of javakamal kotecha
 
Java packages and access specifiers
Java packages and access specifiersJava packages and access specifiers
Java packages and access specifiersashishspace
 
Java - Interfaces & Packages
Java - Interfaces & PackagesJava - Interfaces & Packages
Java - Interfaces & PackagesArindam Ghosh
 
Built in classes in java
Built in classes in javaBuilt in classes in java
Built in classes in javaMahmoud Ali
 
5.interface and packages
5.interface and packages5.interface and packages
5.interface and packagesDeepak Sharma
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singhdheeraj_cse
 
Java packages and access specifiers
Java packages and access specifiersJava packages and access specifiers
Java packages and access specifiersasbasb82
 
Access Protection
Access ProtectionAccess Protection
Access Protectionmyrajendra
 
Java - Exception Handling
Java - Exception HandlingJava - Exception Handling
Java - Exception HandlingPrabhdeep Singh
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classesShreyans Pathak
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in javaPratik Soares
 
Java exception handling ppt
Java exception handling pptJava exception handling ppt
Java exception handling pptJavabynataraJ
 

Viewers also liked (20)

Java packages
Java packagesJava packages
Java packages
 
Packages and inbuilt classes of java
Packages and inbuilt classes of javaPackages and inbuilt classes of java
Packages and inbuilt classes of java
 
java packages
java packagesjava packages
java packages
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Java packages and access specifiers
Java packages and access specifiersJava packages and access specifiers
Java packages and access specifiers
 
Java packages oop
Java packages oopJava packages oop
Java packages oop
 
Java - Interfaces & Packages
Java - Interfaces & PackagesJava - Interfaces & Packages
Java - Interfaces & Packages
 
Built in classes in java
Built in classes in javaBuilt in classes in java
Built in classes in java
 
5.interface and packages
5.interface and packages5.interface and packages
5.interface and packages
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
 
Java packages and access specifiers
Java packages and access specifiersJava packages and access specifiers
Java packages and access specifiers
 
Access Protection
Access ProtectionAccess Protection
Access Protection
 
Java - Exception Handling
Java - Exception HandlingJava - Exception Handling
Java - Exception Handling
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classes
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Java exception handling ppt
Java exception handling pptJava exception handling ppt
Java exception handling ppt
 
Core java slides
Core java slidesCore java slides
Core java slides
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Webquest
WebquestWebquest
Webquest
 
Java package
Java packageJava package
Java package
 

Similar to Packages in Java - Group Classes and Avoid Namespaces

Similar to Packages in Java - Group Classes and Avoid Namespaces (20)

Javapackages 4th semester
Javapackages 4th semesterJavapackages 4th semester
Javapackages 4th semester
 
packages unit 5 .ppt
packages  unit 5 .pptpackages  unit 5 .ppt
packages unit 5 .ppt
 
packages.ppt
packages.pptpackages.ppt
packages.ppt
 
packages.ppt
packages.pptpackages.ppt
packages.ppt
 
Java packages
Java packagesJava packages
Java packages
 
Packages
PackagesPackages
Packages
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Packages
PackagesPackages
Packages
 
9 cm604.26
9 cm604.269 cm604.26
9 cm604.26
 
Class notes(week 7) on packages
Class notes(week 7) on packagesClass notes(week 7) on packages
Class notes(week 7) on packages
 
Packages(9 cm604.26)
Packages(9 cm604.26)Packages(9 cm604.26)
Packages(9 cm604.26)
 
7.Packages and Interfaces(MB).ppt .
7.Packages and Interfaces(MB).ppt             .7.Packages and Interfaces(MB).ppt             .
7.Packages and Interfaces(MB).ppt .
 
Package.pptx
Package.pptxPackage.pptx
Package.pptx
 
packages.ppt
packages.pptpackages.ppt
packages.ppt
 
THE PACKAGES CONCEPT IN JAVA PROGRAMMING.pptx
THE PACKAGES CONCEPT  IN JAVA PROGRAMMING.pptxTHE PACKAGES CONCEPT  IN JAVA PROGRAMMING.pptx
THE PACKAGES CONCEPT IN JAVA PROGRAMMING.pptx
 
Java Packages
Java Packages Java Packages
Java Packages
 
Lecture-12 Java Packages and GUI Basics.ppt
Lecture-12 Java Packages and GUI Basics.pptLecture-12 Java Packages and GUI Basics.ppt
Lecture-12 Java Packages and GUI Basics.ppt
 
20-packages-jar.ppt
20-packages-jar.ppt20-packages-jar.ppt
20-packages-jar.ppt
 

More from Abhishek Khune (16)

07 java collection
07 java collection07 java collection
07 java collection
 
Clanguage
ClanguageClanguage
Clanguage
 
Java Notes
Java NotesJava Notes
Java Notes
 
Threads
ThreadsThreads
Threads
 
Sorting
SortingSorting
Sorting
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
 
Week0 introduction
Week0 introductionWeek0 introduction
Week0 introduction
 
Binary trees
Binary treesBinary trees
Binary trees
 
Applets
AppletsApplets
Applets
 
Clanguage
ClanguageClanguage
Clanguage
 
06 abstract-classes
06 abstract-classes06 abstract-classes
06 abstract-classes
 
Java unit3
Java unit3Java unit3
Java unit3
 
Java unit2
Java unit2Java unit2
Java unit2
 
Linux introduction
Linux introductionLinux introduction
Linux introduction
 
Shared memory
Shared memoryShared memory
Shared memory
 
Lecture 14 (inheritance basics)
Lecture 14 (inheritance basics)Lecture 14 (inheritance basics)
Lecture 14 (inheritance basics)
 

Recently uploaded

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 

Recently uploaded (20)

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 

Packages in Java - Group Classes and Avoid Namespaces

  • 2. Packages • Packages enable grouping of functionally related classes • Package names are dot separated, e.g., java.lang. • Package names have a correspondence with the directory structure • Packages Avoid name space collision. There can not be two classes with same name in a same Package But two packages can have a class with same name. • Exact Name of the class is identifed by its package structure. << Fully Qualified Name>> java.lang.String ; java.util.Arrays; java.io.BufferedReader ; java.util.Date
  • 3. How To Create a Package • Packages are mirrored through directory structure. • To create a package, First we have to create a directory /directory structure that matches the package hierarchy. • Package structure should match the directory structure also. • To make a class belongs to a particular package include the package statement as the first statement of source file.
  • 4. Exercise Creating Packages mypackage mypackageBmypackageA ABC DEG IJK XYZ S1,S2,S3 S4,S5,S6 A,B,C D,E,F A,B,C,I,J,K X,Y,Z Package ABC and IJK have classes with same name. A class in ABC has name mypackage.mypackageA.ABC.A A class in IJK has name mypackage.mypackageB.IJK.A
  • 5. How to make a class Belong to a Package • Include a proper package statement as first line in source file Make class S1 belongs to mypackageA package mypackage.mypackageA; public class S1 { public S1( ) { System.out.println("This is Class S1"); } } Name the source file as S1.java and compile it and store the S1.class file in mypackageA directory
  • 6. Make class S2 belongs to mypackageA package mypackage.mypackageA; public class S2 { public S2( ) { System.out.println("This is Class S2"); } } Name the source file as S2.java and compile it and store the S2.class file in mypackageA directory
  • 7. Make class A belongs to IJK package mypackage.mypackageB.IJK; public class A { public A( ) { System.out.println("This is Class A in IJK"); } } Name the source file as A.java and compile it and store the A.class file in IJK directory << Same Procedure For all classes>>
  • 8. Importing the Package • import statement allows the importing of package • Library packages are automatically imported irrespective of the location of compiling and executing program • JRE looks at two places for user created packages (i) Under the current working directory (ii) At the location specified by CLASSPATH environment variable • Most ideal location for compiling/executing a program is immediately above the package structure.
  • 9. Example importing import mypackage.mypackageA.ABC; import mypackage.mypackageA.ABC.*; class packagetest { public static void main(String args[]) { B b1 = new B(); C c1 = new C(); } } This is Class B This is Class C << packagetest.java>> << Store it in location above the package structure. Compile and Execute it from there>>
  • 10. import mypackage.mypackageA.ABC.*; Import mypackage.mypackageB.IJK.*; class packagetest { public static void main(String args[]) { A a1 = new A(); } } << What’s Wrong Here>> << class A is present in both the imported packages ABC and IJK. So A has to be fully qualified in this case>> mypackage.mypackageA.ABC.A a1 = new mypackage.mypackageA.ABC.A(); OR mypackage.mypackageB.IJK.A a1 = new mypackage.mypackageB.IJK.A();
  • 11. CLASSPATH Environmental Variables • CLASSPATH Environmental Variable lets you define path for the location of the root of the package hierarchy • Consider the following statement : package mypack; What should be true in order for the program to find mypack. (i) Program should be executed from the location immediately above mypack OR (ii) mypack should be listed in the set of directories for CLASSPATH