Questions And Answers

More Tutorials

Java Create Packages

How to create a package in Java :

javac -d Mockstacks java

The above code creates a packages folder.

java Mockstacks java 

The above code creates Mockstacks class.

We can also create inner packages by adding packages inner as the package name.
These packages once created can be used by other classes.



import java.util.Scanner;
//import java.util.*;
public class packages {
    public static void main(String[] args) {
        Scanner sc = new Scanner(;
        // java.util.Scanner sc = new java.util.Scanner(;
        int a = sc.nextInt();
        System.out.println("This is my scanner taking input as " + a);


In this page (written and validated by ) you learned about Java Create Packages . What's Next? If you are interested in completing Java tutorial, your next topic will be learning about: Java Access Modifiers.

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

Share On:

Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.