Package creation in Java | Java Online Tutorials

This Java Online Tutorials  “Package creation in Java” post explains clearly how to create package and how to compile source code which contains package statement in java.


 

Create User Package in Java:

  • ‘package’ is a keyword used to create user packages in Java.
  • ‘package’ statement must be placed at the top of java source file.
  • ‘import’ statements followed by package statement in java file.

 

Compile source file which contains package statement:

  • It is different to compile source file which contains package statement.
  • ‘-d’ is used to create package if package doesn’t exists.
  • Compiler is responsible for creating required package in the given path to generate class file.

Compile source file which contains package statement

 

Program Execution:

Share this