Conext Menu -> Debug ... main() simply failed with "Error: Could not find or load main class"
Hi,
I have a maven project with multi-modules, and everything work fine on NetBeans since maven first class supported. Once I switch to IntelliJ, I cannot simple use IDE simple clicks to Run or Debug a main class which placed in ./src/test/java.
The exact steps: 1. open the main java code in editor window ; 2. right click in editor window, choose Debug '....main()' ; 3. Build was triggered which is successful in Run windows below ; 4. In Debug windows below it trigger maven plugin "[INFO] --- exec-maven-plugin:1.6.0:exec (default-cli) @ ..." which looks good as I run on NetBeans, but the following log:
Listening for transport dt_socket at address: 49753
Connected to the target VM, address: '127.0.0.1:49753', transport: 'socket'
Error: Could not find or load main class ...
I was stuck on this issue for 2 days, I have tried to look around Run -> Edit Configurations, but nothing i can do to tell IntelliJ how to find out the main class. Help!
Please sign in to leave a comment.
Try placing the Java class you are working with into a package like that:
Thanks for reply. As I said, it works properly on NetBeans or pure command line using mvn, it goes without saying that the project layout is proper comply with maven. Class which not placed in the right folder won't pass mvn compile.
This is project-specific issue. So, please share the project where the issue could be reproduced.
Problem solved, thanks to Andrey
https://intellij-support.jetbrains.com/hc/en-us/requests/2979545?page=1
For others with the same concern:
It is needed to disable this option: Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | Runner | Delegate IDE build/run actions to Maven