Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ. Debug a program even if it does not compile

I have a Java project in IntelliJ that compiles, and now I am slowly changing.

Is there a way to ask IntelliJ to run the project, even if some parts of the code still do not compile? If so, how?

Why I would need this, you ask? see this ticket: IDEA-61945 Run and Debug commands should ignore compile errors not related to the main being run. http://youtrack.jetbrains.net/issue/IDEA-61945?query=it#tab=Comments

Please, do not answer this post questioning whether I should or I should not need to run a project even if it does not compile. please.

If not possible in IntelliJ, is it possible in maven? How?

like image 610
David Portabella Avatar asked Sep 14 '11 14:09

David Portabella


2 Answers

In Intellij 12 you also have the following option (which personally I find the best one):

  • Go to Edit configuration of your launcher
  • Go to the before launch section
  • If 'Make' is in the list: remove it
  • Add 'Make, no error check'

Now, when you run, a make will still be done automatically but the run will continue even if the are compilation errors.

Regarding the above debate; I think it makes perfect sense to be able to run a part of the code that does compile even if another part of the code does not not; e.g. if that other part of the code belongs to a module that is in your project but not involved when running.

like image 112
Stijn Geukens Avatar answered Oct 14 '22 10:10

Stijn Geukens


I ran into this exact same problem at work today. Before now, I probably would have been quick to jump on the bandwagon of, "Why would you ever want to do that?" Turns out that Eclipse lets you do exactly this, and if you start working concurrently with other developers who depend on this feature (which is to say, check in code that doesn't compile), it's handy to be able to do the same in IDEA!

And lucky for us IDEA users, you can. Follow these instructions from the FAQ for Eclipse Users, and you're good to go:

To be able to run code with errors, you can select the Eclipse compiler in Settings dialog, Compiler, Java Compiler and add the -proceedOnError option to the Additional command line parameters for the compiler.

The only thing that's lame is that it's not quite as seamless as in Eclipse. First, you'll have to untick the option to Make before run because IDEA won't run if make fails. Then, you'll have to remember to build before running. With those caveats, though, you should be able to accomplish what you're after.

like image 44
stevevls Avatar answered Oct 14 '22 10:10

stevevls