Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run single class ignoring compilation error in other class

I am using IntelliJ IDEA 2017.3. I have a project called "test", which has two classes under the src folder:

  • Main, has main method to print out "Hello World"
  • CompileErrorClass, has one method with compile errors

project structure picture

Those two class have no dependencies. I was trying to run the main() in the Main class, and set the before launch to "build, no error check"

run settings picture

I got an error message

"Error: Could not find or load main class Main".

When I fixed the compile error in CompileErrorClass, the main() worked as expected. Or if I ran the same project in Eclipse, it worked fine even with compile error.

How can I setup the run configurations in IntelliJ to run a single class ignoring the compile errors in other class without dependencies?

like image 616
nahs Avatar asked Dec 23 '17 00:12

nahs


1 Answers

To be able to run code with errors you need to make a change in the settings. Go to Build, Execution, Deployment | Compiler | Java Compiler and set the Use compiler: combobox to Eclipse and enable the proceed on errors checkbox. This allows to compile classes even when they have errors.

To start a Run Configuration when the project has errors, you will need Build, no error check in the Before Launch section, instead of Build.

like image 93
Bas Leijdekkers Avatar answered Sep 19 '22 18:09

Bas Leijdekkers