Tukaram Bhosale
Tukaram Bhosale

Reputation: 368

Java package folder naming conventions

This is very entry level question and might have been answered already.
My question is, what is the correct way to name my package folders?
for example, I want to have package named - com.stack.abc
Option A- shall I create package folder with name - com.stack.abc?
or
Option B- shall I create folder structure as shown below?

com   
  |_stack   
        |_abc

To summarise, I should have only one folder (com.stack.abc) or 2 subfolders under com?

Upvotes: 1

Views: 9041

Answers (2)

Jason
Jason

Reputation: 5246

Edit due to main post edited;

You would create 3 different folders. One folder called com, one folder inside com called stack, and one folder inside stack called abc. On some, or most IDEAs, it will look like 1 folder because it looks like com.stack.abc but it's really 3 folders.

Generally you define the source folder (top level of all java files) as

src/main/java/

Then you define the package that represents your website (if any)

com.stack.abc

This would resolve to;

abc.stack.com

The entire directory would look like this;

src/main/java/com/stack/abc

This might be a helpful link into packaging conventions.

Upvotes: 1

Dravidian
Dravidian

Reputation: 339

To your question, com.stack.abc should be the folder hierarchy structure.

com |-stack |-abc

Upvotes: 1

Related Questions