Reputation: 5361
What is an acceptable folder structure for Java projects in IntelliJ IDEA?
Multiple sources (like this) suggest the following structure:
.
│ .idea
└── src
├── main
│ ├── java
│ │ └── com.simpleproject
│ │ └── SimpleClass.java
│ └── resources
└── test
├── java
│ └── com.simpleproject
│ └── SimpleClassTest.java
└── resources
I know this has worked before, but right now it is complaining java.lang.SecurityException: Prohibited package name: java
Apparently, java
is not allowed as a package name. I don't understand why it's sometimes acceptable and sometimes not acceptable. Can someone provide a complete example of an acceptable project folder structure in a Java project in IntelliJ IDEA?
Upvotes: 24
Views: 83432
Reputation: 219
Let's say you have a multi-module project of Maven and you want to open it in IntelliJ, you click:
Upvotes: 0
Reputation: 1249
Am using Mac OSx, In my case the IntelliJ did not created the src/main/java directories for me and i tried to create those directories but i cannot see create directory under right click menu of the project.
Hence i created those directories manually via terminal / finder. Then i went to File -> Project Structure
and marked src/main/java
as sources
Upvotes: 0
Reputation: 5247
In Project Structure Settings,select Modules -> choose any of the mark as to set the folder type to be of specific type. Then do mvn clean and mvn compile
Upvotes: 1
Reputation: 43
Simply close intellij and delete any existing .IML file from the project root will do it
Upvotes: 0
Reputation: 14041
That is the basic folder structure of a maven project. IntelliJ usually recognizes this and sets up sensical defaults for you.
If it didn't (or if it did but you modified them afterwards), you need to set up your java folder as the sources
folder (i.e. the folder that contains the source code).
For this, you need to:
File > Project Structure
src/main/java
folder and select itSources
Repeat for test folder (mark as 'Tests'), resources (mark as 'Resources'), test-resources (mark as 'Test Resources'), etc.
Upvotes: 40
Reputation: 807
Your configuration in the IntelliJ's File > Project Structure
page will be overridden by the project's pom.xml
after every clean install
. To prevent this, you need to configure the source directory in pom.xml
as below:
<sourceDirectory>src/main/java</sourceDirectory>
Upvotes: 4