Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ Idea, run code regardless of errors in unrelated project files

One thing that I miss from Eclipse is that I can't run code for testing various things (think short main()) if some totally unrelated files in my project contain errors. I've read in FAQ that I can use Eclipse compiler with -proceedOnErrors argument but it still doesn't work. Temporarily fixing unfinished code to compile is not really what I want.

I should note that I use Scala plugin too but still majority of my code are Java files.

like image 835
woky Avatar asked Jun 01 '12 14:06

woky


People also ask

How do I get rid of compilation error in IntelliJ?

Run/Debug Configurations -> Your Application -> Configuration -> Before launch: Build, Activate tool window -> remove the "Build" line with the Minus symbol. That works! :) Thank You Vic!

Why is IntelliJ not showing compilation errors?

In "Settings" --> Build, Execution, Deployment --> "Compiler" check the checkbox "Build project automatically". This will immediately show any compile errors in the project tree.

How do I enable errors in IntelliJ?

Configure error highlighting Press Ctrl+Alt+S to open the IDE settings and select Editor | Color Scheme | General. You can also configure highlighting from inspection settings: go to Editor | Inspections, click any enabled inspection, and from the Highlighting in editor list, select Edit Highlighting.


2 Answers

Modify your configuration to use Make, no error check option instead of Make.

For more information see this answer

Note that this may not be enough in your use case. Last resort is to use the solution provided by Vics answer.

like image 107
Lovro Pandžić Avatar answered Sep 20 '22 12:09

Lovro Pandžić


Well, you can do it. The important part, of course, that the class with the main function compiles.

There are two ways you can go:

  1. Compile the class that you want to run only (CTRL Shift F9). Run the main function with a right click. It will fail, but IntelliJ will automagically create a temporary running configuration for this main function. Now edit this configuration and uncheck the option to "Make before launch". Then go back to the file and launch the main as before.
  2. Go to the configurations screen, then Defaults and then Application pane. Uncheck the "Make before launch" option and then you're good to go, as in section one, for any main function you'll encounter/create in this project.

Edit

This answer is outdated, and @ipandzic's answer should be used

like image 33
Vic Avatar answered Sep 21 '22 12:09

Vic