I have a JAVA project in IntelliJ IDEA that has multiple packages. But some files in my packages have their own main()
method and can be run on their own.
However if I do a right click on given file and choose "Debug/Run File.main()" IntelliJ will try to build all the files in the package, no matter if they are included or not.
Is there any way to run just that one file?
How to do run configuration in IntelliJ IDEA? You just have to open your run config settings (the dropdown in your toolbar or shift + alt + F10 -> Edit configurations). Select the configuration you want to run and remove the make entry at the bottom (before launch section).
Rerun a single testRight-click a test on the Test Runner tab of the Run tool window and select Run 'test name'.
If you press and hold the Ctrl / ⌘ button while dragging the arrow, the IDE will highlight all the lines in green. When you drop the arrow, you won't jump to the line of code. Instead, the IDE will act as if you have used the Run to Cursor (⌥F9) action.
You can remove the Make task in your run configuration. But you have to compile the single class manually before launch (Right click or Build -> Compile your class).
Or you could even try to compile the whole project if you need more than a single class. This might work if you have no dependencies to a broken class.
To run a single file in IntelliJ IDEA:
Way 1:
Right-click somewhere in the editing area and select Run 'ClassName.main()'. Say you want to run HelloWorld, you should do the steps below:
Way 2:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With