1

I have installed OpenJDK 11 (version 11.0.2) on macOS Mojave (version 10.14.2) following these steps. Then I tried to launch a JShell session in Apache NetBeans IDE 10.0, but I'm getting this error:

|  Could not initialize JShell: Launching JShell execution engine threw: Failed remote launch: java.util.concurrent.TimeoutException @ com.sun.jdi.CommandLineLaunch (defaults: home=/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home, options=, main=, suspend=true, quote=", vmexec=java) -- {home=home=/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home, options=options=-classpath /Users/Steve/Apps/netbeans/java/modules/ext/nb-mod-jshell-probe.jar:, main=main=org.netbeans.lib.jshell.agent.AgentWorker 49866, suspend=suspend=true, quote=quote=", vmexec=vmexec=java}
|   caused by: Failed remote launch: java.util.concurrent.TimeoutException @ com.sun.jdi.CommandLineLaunch (defaults: home=/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home, options=, main=, suspend=true, quote=", vmexec=java) -- {home=home=/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home, options=options=-classpath /Users/Steve/Apps/netbeans/java/modules/ext/nb-mod-jshell-probe.jar:, main=main=org.netbeans.lib.jshell.agent.AgentWorker 49866, suspend=suspend=true, quote=quote=", vmexec=vmexec=java}
|   caused by: null

How do I fix the issue?

Looking at the Java Platform Manager in the IDE I can see that the JDK is set correctly and a simple Java SE application using Maven compiles and runs fine.

Update

From About NetBeans:

Java: 11.0.2; OpenJDK 64-Bit Server VM 11.0.2+9
Runtime: OpenJDK Runtime Environment 11.0.2+9

From Plugins:

Java Shell
Version: 1.2.1
Source: Apache NetBeans IDE 10.0 (Build
incubator-netbeans-release-380-on-20181217)

There are no other JDK installed on the machine.

I can invoke jshell successfully in the NetBeans Terminal:

$ jshell                                                                                                   
|  Welcome to JShell -- Version 11.0.2
|  For an introduction type: /help intro

jshell> 

IDE Log when opening Java Platform Shell:

INFO [org.netbeans.modules.jshell.support.ShellSession]: Error in JSHell
java.util.concurrent.TimeoutException
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204)
    at jdk.jshell/jdk.jshell.execution.JdiInitiator.timedVirtualMachineCreation(JdiInitiator.java:244)
    at jdk.jshell/jdk.jshell.execution.JdiInitiator.launchTarget(JdiInitiator.java:137)
Caused: java.lang.InternalError: Failed remote launch: java.util.concurrent.TimeoutException @ com.sun.jdi.CommandLineLaunch (defaults: home=/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home, options=, main=, suspend=true, quote=", vmexec=java) -- {home=home=/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home, options=options=-classpath /Users/Steve/Apps/netbeans/java/modules/ext/nb-mod-jshell-probe.jar:, main=main=org.netbeans.lib.jshell.agent.AgentWorker 50384, suspend=suspend=true, quote=quote=", vmexec=vmexec=java}
    at jdk.jshell/jdk.jshell.execution.JdiInitiator.reportLaunchFail(JdiInitiator.java:300)
    at jdk.jshell/jdk.jshell.execution.JdiInitiator.launchTarget(JdiInitiator.java:141)
    at jdk.jshell/jdk.jshell.execution.JdiInitiator.<init>(JdiInitiator.java:110)
    at org.netbeans.lib.nbjshell.LaunchJDIAgent.create(LaunchJDIAgent.java:217)
    at org.netbeans.lib.nbjshell.LaunchJDIAgent.access$000(LaunchJDIAgent.java:62)
    at org.netbeans.lib.nbjshell.LaunchJDIAgent$1.generate(LaunchJDIAgent.java:180)
    at org.netbeans.modules.jshell.tool.JShellLauncher$CaptureExecControl.generate(JShellLauncher.java:240)
    at jdk.jshell/jdk.jshell.JShell.<init>(JShell.java:126)
Caused: java.lang.IllegalStateException: Launching JShell execution engine threw: Failed remote launch: java.util.concurrent.TimeoutException @ com.sun.jdi.CommandLineLaunch (defaults: home=/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home, options=, main=, suspend=true, quote=", vmexec=java) -- {home=home=/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home, options=options=-classpath /Users/Steve/Apps/netbeans/java/modules/ext/nb-mod-jshell-probe.jar:, main=main=org.netbeans.lib.jshell.agent.AgentWorker 50384, suspend=suspend=true, quote=quote=", vmexec=vmexec=java}
    at jdk.jshell/jdk.jshell.JShell.<init>(JShell.java:139)
    at jdk.jshell/jdk.jshell.JShell$Builder.build(JShell.java:405)
    at org.netbeans.modules.jshell.tool.JShellLauncher.createJShellInstance(JShellLauncher.java:258)
    at org.netbeans.modules.jshell.support.ShellSession$Launcher.createJShellInstance(ShellSession.java:624)
    at org.netbeans.modules.jshell.tool.JShellTool.resetState(JShellTool.java:745)
    at org.netbeans.modules.jshell.tool.JShellLauncher.resetState(JShellLauncher.java:207)
    at org.netbeans.modules.jshell.tool.JShellLauncher.ensureLive(JShellLauncher.java:195)
    at org.netbeans.modules.jshell.tool.JShellLauncher.getJShell(JShellLauncher.java:201)
    at org.netbeans.modules.jshell.support.ShellSession.initJShell(ShellSession.java:829)
    at org.netbeans.modules.jshell.support.ShellSession.getJShell(ShellSession.java:309)
[catch] at org.netbeans.modules.jshell.support.ShellSession.lambda$null$2(ShellSession.java:514)
    at org.netbeans.modules.jshell.model.ConsoleModel$ModelAccImpl.execute(ConsoleModel.java:1104)
    at org.netbeans.modules.jshell.support.ShellSession.lambda$start$3(ShellSession.java:510)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
    at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
    at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
Boris
  • 22,667
  • 16
  • 50
  • 71
  • [1] This looks like a NetBeans bug. There was a similar resolved issue with NetBeans 9.0. See [NETBEANS-133 Problems with JShell in NetBeans on Mac OSX](https://issues.apache.org/jira/browse/NETBEANS-133?jql=text%20~%20%22jshell%20TimeoutException%22), and in particular the **Comments** tab. [2] Unfortunately I can only suggest that you raise a high priority Bug Report with NetBeans, and to do that you will first have to [sign up](https://issues.apache.org/jira/secure/Signup!default.jspa). – skomisa Jan 25 '19 at 16:36
  • As a flaky workaround you could try downloading NetBeans 9.0 to see if **jshell** works there. Although NB 9.0 didn't _officially_ support JDK 11 it worked fine, and NB 9.0 should contain the fix for your problem. – skomisa Jan 25 '19 at 16:39

2 Answers2

2

This is not really an answer - it's more a request for further information - but my questions and suggestions don't fit in the comments:

  • This is working for me using OpenJDK 11.0.2 on NetBeans 10.0, though I am running on Windows 10.
  • What are the values shown on the screen for Java and Runtime when you do Help > About in NetBeans? The JDK displayed won't necessarily be the same as that shown in Java Platform Manager:

    helpAbout

  • Check that the JShell plugin is installed:

    • Select Tools > Plugins and click the Installed tab.
    • Check the Show Details checkbox and sort the entries alphabetically by clicking the Name column header (if necessary).
    • Scroll down and verify that you can select an entry named Java Shell. Its absence would explain your problem:

      installedPlugins

  • Remove any unused/unwanted JDK installations from your machine. Since you have installed JDK 11.0.2 you probably don't want or need any earlier versions on your machine (unless one of them is being used to run NetBeans as shown in the Help > About screen as described above).

  • Verify that you can invoke jshell from your terminal using OpenJDK 11.0.2 (to determine whether the jshell problem is confined to NetBeans).

Finally, as a sanity check, open the NetBeans log (View > IDE Log) and review it for any issues relating to jshell. Update your question if you find anything. These lines in my log contained "jshell", and hopefully you see something similar:

WARNING [org.netbeans.core.modules]: the modules [org.netbeans.modules.java.hints, org.netbeans.modules.jshell.support, org.netbeans.modules.maven.hints, org.netbeans.modules.maven.j2ee, org.netbeans.modules.web.beans] use org.netbeans.modules.java.hints.legacy.spi which is deprecated: Use Java Hints SPI (org.netbeans.spi.java.hints) instead.
    org.netbeans.lib.nbjshell [1.6 incubator-netbeans-linux-934-on-20181203]
    org.netbeans.modules.jshell.support [1.4.0.25.55.17.1.4 incubator-netbeans-linux-934-on-20181203]
    org.netbeans.lib.nbjshell9 [1.3 incubator-netbeans-linux-934-on-20181203]
    --add-opens=jdk.jshell/jdk.jshell=ALL-UNNAMED
    --add-modules=jdk.jshell
WARNING [org.openide.loaders]: Should override getLookup() in class org.netbeans.modules.jshell.env.JShellDataObject, e.g.: [MultiDataObject.this.]getCookieSet().getLookup()
WARNING [org.openide.filesystems.Ordering]: Found same position 20,000 for both Separator-before-shell-reset.instance and jshell-reset.shadow
INFO [org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater]: Indexing of: C:\Users\johndoe\AppData\Local\NetBeans\Cache\dev\jshell\junk took: 65 ms (New or modified files: 0, Deleted files: 0) [Adding listeners took: 0 ms]
WARNING [org.openide.filesystems.Ordering]: Not all children in / marked with the position attribute: [org-netbeans-modules-lsp-client-bindings-CompletionProviderImpl.instance], but some are: [org-netbeans-modules-jshell-editor-HistoryCompletionProvider.instance, org-netbeans-modules-jshell-editor-CommandCompletionProvider.instance]
WARNING [org.openide.filesystems.Ordering]: Not all children in / marked with the position attribute: [org-netbeans-modules-lsp-client-bindings-CompletionProviderImpl.instance], but some are: [org-netbeans-modules-parsing-ui-WaitScanFinishedCompletionProvider.instance, org-netbeans-modules-editor-java-JavaCompletionProvider.instance, org-netbeans-modules-jshell-editor-HistoryCompletionProvider.instance, org-netbeans-modules-java-editor-javadoc-JavadocCompletionProvider.instance, org-netbeans-lib-editor-codetemplates-CodeTemplateCompletionProvider.instance, org-netbeans-modules-j2ee-persistence-editor-completion-JPACodeCompletionProvider.instance, org-netbeans-modules-websvc-editor-completion-WSCompletionProvider.instance, org-netbeans-modules-spellchecker-completion-WordCompletion.instance]
WARNING [org.netbeans.modules.parsing.impl.TaskProcessor]: ParserManager.parse called in AWT event thread by: org.netbeans.modules.jshell.parsing.ConsoleEmbeddingProvider.getEmbeddings(ConsoleEmbeddingProvider.java:62)
skomisa
  • 16,436
  • 7
  • 61
  • 102
1

I could not execute JavaShell on a project as well, the new Netbeans is broken in almost anything that is not compile a simple java or maven project, but to test a huge library with no documentation I had to solve this.

As a workaround I did these steps (same NB/JRE configuration as yours):

  1. open the Platform Shell from the menu tools>Open Java Platform Shell instead of directly executing it from the project
  2. import the library I need into the classpath.

Follows an example.

[1]-> /classpath C:\Users\brazorv\Documents\NetBeansProjects\JavaTest\dist\JavaTest.jar
|  Path 'C:\Users\brazorv\Documents\NetBeansProjects\JavaTest\dist\JavaTest.jar' added to classpath
[1]-> import javatest.JavaTest;
[2]-> JavaTest jt = new JavaTest();
|  jt ==> javatest.JavaTest@2de8284b
[3]-> jt.main(new String[]{});
[4]-> (my method just prints something on the terminal  output)

That's it. I hope this is helpful.

Sandor Mezil
  • 390
  • 1
  • 4
  • 16