IntelliJ put package and imports below file header

formatting, import, intellij-idea, java

Solution

In your IDE Settings under File and Code Templates - Templates tab

For the template you want i.e. Class you want to have the File Header above the package information

Like this (I think this will only help for newly created files however, but for existing files the imports appear to just come in where the other imports are):

#parse("File Header.java")
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end

public class ${NAME} {
}

This is my setup and the auto imports always occur below what I have defined for my `License.java` but before my File Header

Problem

In IntelliJ, I have auto imports enabled for my java project. When they import, they seem to show up above my file header. Is there a way to have the package and import statements appear below the file header comment?

Original source