'IntelliJ : Cannot resolve method 'run(java.lang.Class, String[])'
I've encountered a problem where on all of my applications, there's a red cross on the top right. I can run it, but the cross doesn't seem to go away.
I've opened the run/debug configurations and it says Warning : Main method not found. I don't understand why it's not found when I already have a corresponding main class and method for each and every application.
I tried to close the project, restarting IntelliJ, restarting my laptop, refreshing my desktop, refresh Gradle by clicking Reimport All Gradle Projects, rebuild the project and clicking Invalidate Caches / Restart. I also tried other suggestions I found on StackOverflow such as deleting the .idea folder. Nothing. The red cross still shows up. I've also realized that I do not have the out folder in all of my Applications.
Solution 1:[1]
In Project Settings, First make sure SDK path is correct. Preferably install and use your own SDK. Then use the same SDK in Project and Modules in Project Settings.
Solution 2:[2]
I just set the language level to equal my SDK version at Project Structure. Finally, it is disappeared.
Solution 3:[3]
Try to copy src and gradle folders and buil.gradle and settings,gradle files in separate folder. Then open this new folder as new project in intellij. Then intellij will propose Import as gradle project... - push it. If problem remained see you build.gradle
Solution 4:[4]
File->Project structure ->SDKs
- Choose JDK home path, if no jdk is in the path,
- you'll see an icon download jdk
- download then ok
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Arjang |
Solution 2 | Ethan |
Solution 3 | Valeriy K. |
Solution 4 | Otobong Jerome |