Ankit Singh
Ankit Singh

Reputation: 277

How Default package is created and where?

In this How Default Package is Created where class file is stored

class Package
{
    public static void main(String[] args) {
         System.out.println("Default Package");
    }
}

Upvotes: 1

Views: 468

Answers (2)

João Esperancinha
João Esperancinha

Reputation: 1159

The default package location is located in the source folder of your project. If we are talking about java then that is just a package without name.

You can see this even better if you try to compile things without an IDE like this

javac Package.java

which results in a Package.class file. And if you run:

java Package 

You will get

Default Package

As expected. And as you will see, there is no package directory created and everything works.

Using Java in the command line helps a lot understanding these commands and to learn how to use it checkout out these links:

  1. The javac command for JDK 17 in the Oracle Webpage
  2. The java command for JDK 17 in the Oracle Webpage

Upvotes: 0

arjun99
arjun99

Reputation: 358

When we create a java class and do not mention any package name for creating this particular class within any java/web project the eclipse /netbeans will automatically create the default package.

Upvotes: 2

Related Questions