Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA run/debug just one file

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?

like image 755
ddinchev Avatar asked Oct 20 '14 14:10

ddinchev


People also ask

How do I only run one file in IntelliJ?

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).

How do I run a single test case in IntelliJ?

Rerun a single testRight-click a test on the Test Runner tab of the Run tool window and select Run 'test name'.

How do I skip parts of a program while debugging IntelliJ?

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.


2 Answers

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.

like image 106
meistermeier Avatar answered Sep 29 '22 22:09

meistermeier


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:

  1. Right-click somewhere in the editing area
  2. select Run 'HelloWorld.main()' from context menu enter image description here

Way 2:

  1. Open the file in editor
  2. Ctrl+Shift+F10
like image 43
Ripon Al Wasim Avatar answered Sep 29 '22 22:09

Ripon Al Wasim