IntelliJ IDEA: Run single class ignoring compile error in other class

nahs :

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?

Bas Leijdekkers :

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.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=475512&siteId=1