Could not find or load main class com.intellij.idea.Main

Answered

I have updated the JDK to correto-17 and SDK to PhpStorm PS-231.8109.199

But now when I build the plugin and try to execute/debug, after it finish the build process it throws this error:

Error: Could not find or load main class com.intellij.idea.Main
Caused by: java.lang.ClassNotFoundException: com.intellij.idea.Main

Can you help me to solve this or tell me what could be causing it?

0
8 comments

Hi Enrique,

Make sure you use the latest Gradle and Gradle IntelliJ Plugin.

If it doesn't help, please provide a minimal reproducible example.

0

Hi Karol, can you please tell me the steps to do that? I cannot find anything related to Gradle in my project, this was working fine with previous IntelliJ version, I have installed:

IntelliJ IDEA 2023.1 (Community Edition)
Build #IC-231.8109.175, built on March 28, 2023
Runtime version: 17.0.6+10-b829.5 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 16

Kotlin: 231-1.8.20-IJ8109.175

My Gradle plugin says: bundled 231.8109.175

Compiling the plugin and generating the .jar file seems to be working fine, the problem is when trying to debug the project, it fails when trying to create the PhpStorm instance.

This is all I have in debug window:

Connected to the target VM, address: '127.0.0.1:59726', transport: 'socket'
Disconnected from the target VM, address: '127.0.0.1:59726', transport: 'socket'
Error: Could not find or load main class com.intellij.idea.Main
Caused by: java.lang.ClassNotFoundException: com.intellij.idea.Main

Process finished with exit code 1

 

0

Hi Enrique,

Sorry for the delay.

I didn't mean the Gradle IDE plugin. I wrongly assumed you use Gradle IntelliJ Plugin: https://github.com/JetBrains/gradle-intellij-plugin for building and running the plugin. It is the recommended approach for developing plugins, so if you can, I suggest migrating.

See: https://plugins.jetbrains.com/docs/intellij/migrating-plugin-devkit-to-gradle.html

If you must use the DevKit approach for some reason, please share your run configuration.

0

What do you mean with share de run configuration? do you need some specific files o screencap?

0

It can be screenshots. I mean the settings in Run | Edit Configurations....

0

In JRE instead of JDK try to use IntelliJ SDK or default SDK of selected module - this have worked for me in older version od IntelliJ.

0

Thanks Marcin! I can run it now, but only with this config:

If I set the this one:

Then it fails with this error:

Error occurred during initialization of VM
java.lang.NoClassDefFoundError: com/intellij/util/lang/UrlClassLoader
    at java.lang.ClassLoader.defineClass1(java.base@17.0.6/Native Method)
    at java.lang.ClassLoader.defineClass(java.base@17.0.6/ClassLoader.java:1012)
    at java.security.SecureClassLoader.defineClass(java.base@17.0.6/SecureClassLoader.java:150)
    at jdk.internal.loader.BuiltinClassLoader.defineClass(java.base@17.0.6/BuiltinClassLoader.java:862)
    at jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(java.base@17.0.6/BuiltinClassLoader.java:760)
    at jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(java.base@17.0.6/BuiltinClassLoader.java:681)
    at jdk.internal.loader.BuiltinClassLoader.loadClass(java.base@17.0.6/BuiltinClassLoader.java:639)
    at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(java.base@17.0.6/ClassLoaders.java:188)
    at java.lang.ClassLoader.loadClass(java.base@17.0.6/ClassLoader.java:520)
    at java.lang.Class.forName0(java.base@17.0.6/Native Method)
    at java.lang.Class.forName(java.base@17.0.6/Class.java:467)
    at java.lang.ClassLoader.initSystemClassLoader(java.base@17.0.6/ClassLoader.java:1981)
    at java.lang.System.initPhase3(java.base@17.0.6/System.java:2246)
Caused by: java.lang.ClassNotFoundException: com.intellij.util.lang.UrlClassLoader
    at jdk.internal.loader.BuiltinClassLoader.loadClass(java.base@17.0.6/BuiltinClassLoader.java:641)
    at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(java.base@17.0.6/ClassLoaders.java:188)
    at java.lang.ClassLoader.loadClass(java.base@17.0.6/ClassLoader.java:520)
    at java.lang.ClassLoader.defineClass1(java.base@17.0.6/Native Method)
    at java.lang.ClassLoader.defineClass(java.base@17.0.6/ClassLoader.java:1012)
    at java.security.SecureClassLoader.defineClass(java.base@17.0.6/SecureClassLoader.java:150)
    at jdk.internal.loader.BuiltinClassLoader.defineClass(java.base@17.0.6/BuiltinClassLoader.java:862)
    at jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(java.base@17.0.6/BuiltinClassLoader.java:760)
    at jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(java.base@17.0.6/BuiltinClassLoader.java:681)
    at jdk.internal.loader.BuiltinClassLoader.loadClass(java.base@17.0.6/BuiltinClassLoader.java:639)
    at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(java.base@17.0.6/ClassLoaders.java:188)
    at java.lang.ClassLoader.loadClass(java.base@17.0.6/ClassLoader.java:520)
    at java.lang.Class.forName0(java.base@17.0.6/Native Method)
    at java.lang.Class.forName(java.base@17.0.6/Class.java:467)
    at java.lang.ClassLoader.initSystemClassLoader(java.base@17.0.6/ClassLoader.java:1981)
    at java.lang.System.initPhase3(java.base@17.0.6/System.java:2246)
0

Please sign in to leave a comment.