Search code examples
javaintellij-ideaprojects-and-solutions

Configuring IntelliJ IDEA to create main class for new projects


A friend is just starting to learn Java, using IntelliJ. He asks how can he set up some template so creating a new project will contain a default main class.

Currently, when he creates a new project, it has no source files, and he has to add a Run/Debug application configuration manually, and then select the main class.


Solution

  • I don't know if Settings->File Templates is what you have in mind, but I'll point it out just in case.

    You can easily create a class and add a main method by typing "psvm " and filling in the method body. You run it by right clicking on the class and selecting "Run". It's automatically be added to your Run/Config list, you just have to save it to make it permanent.

    But my gut feeling is that IntelliJ has no such a feature for reading somebody's mind about a "default main class", nor should it.