Unable to run main method

已回答

 I want to run a class with main() method, but when I click the run button in the left gutter, it shows Nothing here. It never happened on Windows before.

OS: Ubuntu 18.04

IDEA: 2018.2

JDK: 1.8

JAVA_HOME: /usr/lib/jvm/java-8-oracle


2

I ran into the same issue recently on a freshly imported maven project (this code to be precise : https://github.com/emilybache/GildedRose-Refactoring-Kata/tree/master/Java - Java 1.8 project using Maven) and was unable to run a main() from the source or context menu. Creating a run configuration manually worked.

Disabling the Gradle plugin fixed the issue.

Reenabling the Gradle plugin brought the issue back.

The issue went unnoticed at first because I'm only working with Maven projects and had the Gradle plugin disabled until I had to test something on a project using Gradle.

 

The following error was found several times in idea.log (I can provide full log upon request)

 

2018-08-30 14:56:45,134 [  26129]  ERROR - tion.lineMarker.ExecutorAction - org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrMethodCall
java.lang.NoClassDefFoundError: org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrMethodCall
    at org.jetbrains.plugins.gradle.execution.GradleGroovyScriptRunConfigurationProducer.setupConfigurationFromContext(GradleGroovyScriptRunConfigurationProducer.java:38)
    at org.jetbrains.plugins.gradle.execution.GradleGroovyScriptRunConfigurationProducer.setupConfigurationFromContext(GradleGroovyScriptRunConfigurationProducer.java:25)
    at com.intellij.execution.actions.RunConfigurationProducer.createLightConfiguration(RunConfigurationProducer.java:244)
    at com.intellij.execution.lineMarker.ExecutorAction$Companion.computeConfigurations(ExecutorAction.kt:61)
    at com.intellij.execution.lineMarker.ExecutorAction$Companion.getConfigurations(ExecutorAction.kt:46)
    at com.intellij.execution.lineMarker.ExecutorAction$Companion.access$getConfigurations(ExecutorAction.kt:31)
    at com.intellij.execution.lineMarker.ExecutorAction.getActionName(ExecutorAction.kt:94)
    at com.intellij.execution.lineMarker.RunLineMarkerContributor.getText(RunLineMarkerContributor.java:76)
    at com.intellij.execution.application.ApplicationRunLineMarkerProvider.a(ApplicationRunLineMarkerProvider.java:32)
    at com.intellij.util.containers.ContainerUtil.mapNotNull(ContainerUtil.java:1968)
    at com.intellij.util.containers.ContainerUtil.mapNotNull(ContainerUtil.java:1910)
    at com.intellij.execution.application.ApplicationRunLineMarkerProvider.a(ApplicationRunLineMarkerProvider.java:32)
    at com.intellij.execution.lineMarker.RunLineMarkerProvider.lambda$getLineMarkerInfo$1(RunLineMarkerProvider.java:88)
    at com.intellij.codeInsight.daemon.LineMarkerInfo.getLineMarkerTooltip(LineMarkerInfo.java:125)
    at com.intellij.codeInsight.daemon.LineMarkerInfo$LineMarkerGutterIconRenderer.getTooltipText(LineMarkerInfo.java:177)
    at com.intellij.openapi.editor.impl.EditorGutterComponentImpl$2.lambda$run$0(EditorGutterComponentImpl.java:1497)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:959)
    at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:57)
    at com.intellij.openapi.editor.impl.EditorGutterComponentImpl$2.run(EditorGutterComponentImpl.java:1497)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:736)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
    at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:395)
    at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall PluginClassLoader[org.jetbrains.plugins.gradle, 182.4129.33] com.intellij.ide.plugins.cl.PluginClassLoader@4a7626d3
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:63)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 32 more

4

The disabled plugin should be "Groovy".

2

Alan Htang

We are in process of developing a fix for that. Please vote and follow the YouTrack item: 

https://youtrack.jetbrains.com/issue/IDEA-228180

1

Hello,

Is it possible to manually create run configuration and run main method?

0

Manually create run configuration and run main method is OK

0

Do you face this issue with every project? Is it possible to share idea.log ("Help | Show Log in...") after restarting IDE and reproducing the issue?

0

Looks like it was caused by some built-in plugins that I disabled(I don't know which plugin, there were some errors about plugins in the idea.log), the problem is gone when I enable all the built-in plugins.

0

Thanks for the information!

0

Same situation, but unable to run junit tests.

Tried to enable groovy plugin - no issues appeared.

Looks like developers of gradle plugin forgot to add groovy plugin to dependant in plugin.xml

 

0

I had the same issue - couldn't run the main function or any test using the run button in the left gutter.

This was for all projects, both in Java and Kotlin. 

I tried invalidating caches and restarting - didn't help.

Enabling the Groovy plugin solved the issue.

0

Same for MacOS Mojave,
IntelliJ IDEA 2018.2.5 (Ultimate Edition)
Build #IU-182.4892.20, built on October 16, 2018

Scala/SBT projects.
On another computer, same projects, same OS, IDEA CE ----> just OK.

0

I had the same issue in my unit tests. I just found that Spek plugin was causing an exception and not showing the menu items. You can try disabling the Spek plugin.

0

Please see the issue related to problem gutter run icon doesn't work when Groovy plugin disabled:
https://youtrack.jetbrains.com/issue/IDEA-196305.

Issue should have been fixed in current version:(https://www.jetbrains.com/idea/download/#section=mac). Please update and check if it works correct for you.

Please also see already created issue concerning java.lang.NoClassDefFoundError (GrMethodCall):
https://youtrack.jetbrains.com/issue/IDEA-198173.

Thank you

0

In my case it was the AWS Toolkit Plugin 1.4. An update to 1.5 solved the problem.

Idea: 2019.2

0

I met on the same issue on IntelliJ Idea Ultimate 2019.1:


2019-09-03 12:26:26,887 [2561964] ERROR - tion.lineMarker.ExecutorAction - IntelliJ IDEA 2019.1 Build #IU-191.6183.87
2019-09-03 12:26:26,887 [2561964] ERROR - tion.lineMarker.ExecutorAction - JDK: 1.8.0_202-release; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o
2019-09-03 12:26:26,888 [2561965] ERROR - tion.lineMarker.ExecutorAction - OS: Windows 7
2019-09-03 12:26:26,888 [2561965] ERROR - tion.lineMarker.ExecutorAction - Last Action: GotoDeclaration
2019-09-03 12:26:26,876 [2561953] ERROR - tion.lineMarker.ExecutorAction - com/intellij/execution/application/ApplicationConfigurationOptions
java.lang.NoClassDefFoundError: com/intellij/execution/application/ApplicationConfigurationOptions
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
at com.intellij.util.lang.UrlClassLoader._defineClass(UrlClassLoader.java:306)
at com.intellij.util.lang.UrlClassLoader.defineClass(UrlClassLoader.java:302)
at com.intellij.util.lang.UrlClassLoader._findClass(UrlClassLoader.java:271)
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClassInsideSelf(PluginClassLoader.java:182)
at com.intellij.ide.plugins.cl.PluginClassLoader.tryLoadingClass(PluginClassLoader.java:136)
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:49)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.jetbrains.plugins.cucumber.java.run.CucumberJavaRunConfigurationType$1.createTemplateConfiguration(CucumberJavaRunConfigurationType.java:31)
at com.intellij.execution.actions.RunConfigurationProducer.createLightConfiguration(RunConfigurationProducer.java:265)
at com.intellij.execution.lineMarker.ExecutorAction$Companion.computeConfigurations(ExecutorAction.kt:65)
at com.intellij.execution.lineMarker.ExecutorAction$Companion.getConfigurations(ExecutorAction.kt:50)
at com.intellij.execution.lineMarker.ExecutorAction$Companion.access$getConfigurations(ExecutorAction.kt:31)
at com.intellij.execution.lineMarker.ExecutorAction.getActionName(ExecutorAction.kt:100)
at com.intellij.execution.lineMarker.ExecutorAction.update(ExecutorAction.kt:75)
at com.intellij.execution.lineMarker.LineMarkerActionWrapper.update(LineMarkerActionWrapper.java:85)
at com.intellij.codeInsight.daemon.impl.GutterIntentionAction.isAvailable(GutterIntentionAction.java:65)
at com.intellij.codeInsight.daemon.impl.GutterIntentionMenuContributor.addActions(GutterIntentionMenuContributor.java:105)
at com.intellij.codeInsight.daemon.impl.GutterIntentionMenuContributor.addActions(GutterIntentionMenuContributor.java:70)
at com.intellij.codeInsight.daemon.impl.GutterIntentionMenuContributor.collectActions(GutterIntentionMenuContributor.java:50)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.getActionsToShow(ShowIntentionsPass.java:299)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.getActionsToShow(ShowIntentionsPass.java:254)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.doCollectInformation(ShowIntentionsPass.java:220)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:69)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$null$1(PassExecutorService.java:430)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1166)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:423)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:586)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:532)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:86)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:422)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:398)
at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:164)
at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:218)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:396)
at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:174)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: java.lang.ClassNotFoundException: com.intellij.execution.application.ApplicationConfigurationOptions PluginClassLoader[cucumber-java, 182.3934] com.intellij.ide.plugins.cl.PluginClassLoader@2df61423
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:51)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 42 more

0

Kgulyy, can you please share the sample project where the issue is reproduced for you (please create an issue at the YouTrack attaching the project to it: https://youtrack.jetbrains.com/issues). Thank you.

0

I had the same problem on IntelliJ 2019.3 (build 20191112.2054.fa8c), where it wouldn't run Scala tests.  Disabling the Gradle plugin solved it.

0

Jim, it's unlikely to be the same problem, you are probably affected by this bug which is new to 2019.3 release: https://youtrack.jetbrains.com/issue/IDEA-228180 .

0

IntelliJ should really work with Gradle plug-in developers to fix this. I'm having this issue where clicking the green triangle run button wouldn't do anything (nothing, zero output, no reaction from IntelliJ GUI) for my Groovy project. It bothered me for days and days. Luckily I found this article lying around. After disabling Gradle plug-in, my Groovy application runs. Is it possible to raise a PR for the gradle plug-in project source code? I'm sure many developers will be happy to fix it for them.

0

Unable to execute task Theory, the main method is missing.

Note: Groovy is not disabled.

0

From your screenshot I see that Main.java file is not located under the source root. Is the issue fixed when you press right mouse button on "Theory" -> Mark directory -> As source root?

0

Pranav

`src` subdirectory under `Theory` is not configured as source root for some reason. Could you please provide the details how to obtain this specific course to reproduce the issue? What are your IntelliJ IDEA and EDU plug-in versions?

See https://stackoverflow.com/a/43319356/104891 for more details about this problem.

0

Serge Baranov
Olga Klisho
I used IntelliJ Ultimate 2019.3.4 and latest plugins with comes with it.
The problem was solved when I do usual thing when I don't know what to do. That is "Invalid Cache & Restart". After restart, it asked me for Jdk path as if there was no path mentioned before. And then that's it. Problem solved.

OS: Ubuntu 19.10
Jdk: Openjdk 11.something

0

I had similar issue. Selecting Maven for build was my workaround. I wasn't ready to fiddle with gradle.

0

Hello,

Is it possible to provide sample project example for investigation?

0

请先登录再写评论。