Home > Mobile >  How does IntelliJ run a main class without it being specified in the build.gradle?
How does IntelliJ run a main class without it being specified in the build.gradle?

Time:08-05

When I click the Run Buttton in IntelliJ on a main class, it runs the gradle build with all the tasks. enter image description here

However, I do not have a task that specifically runs the program (Main.main) (no gradle run functionality). How can I mimic that call to Main.main through the terminal without modifying the build.gradle (like how IntelliJ is doing)?

CodePudding user response:

IntelliJ IDEA generates a Gradle script to run it. You can't do it from the terminal in the same way IntelliJ IDEA does.

You can disable Gradle delegation to run directly via the IDE.

CodePudding user response:

You should build a project without gradle to do this.

Select new project -> Java -> Intellij -> Add sample code

Run Main method

Tested in Intellij 2022.2

  • Related