Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-1131

"Execute Java Shell" fails when in a non-modular project

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 9.0
    • None
    • apisupport - Project
    • None

    Description

      I can use the "Execute Java Shell" option when right clicking on a Module Project

      BUT, when I have another project that depends on the Modular project, if I try the "Execute Java Shell" option I get the following failure:

      Could not initialize JShell: Launching JShell execution engine threw: Failed remote launch: java.util.concurrent.ExecutionException: com.sun.jdi.connect.VMStartException: VM initialization failed for: C:\Program Files\Java\jdk-10.0.2\bin\java -classpath C:\Users\Eric\Downloads\incubating-netbeans-java-9.0-bin\netbeans\java\modules\ext\nb-mod-jshell-probe.jar;C:\Users\Eric\Documents\NetBeansProjects\ModProj\dist\M.jar;C:\Users\Eric\Documents\NetBeansProjects\Java10App\build\classes --add-modules M,jdk.jshell --add-reads jdk.jshell=ALL-UNNAMED --module-path C:\Users\Eric\Documents\NetBeansProjects\Java10App\build\classes -Xdebug -Xrunjdwp:transport=dt_shmem,address=javadebug2032,suspend=y org.netbeans.lib.jshell.agent.AgentWorker 63903 @ com.sun.jdi.CommandLineLaunch (defaults: home=C:\Program Files\Java\jdk-10.0.2, options=, main=, suspend=true, quote=", vmexec=java) – {home=home=C:\Program Files\Java\jdk-10.0.2, options=options=-classpath C:\Users\Eric\Downloads\incubating-netbeans-java-9.0-bin\netbeans\java\modules\ext\nb-mod-jshell-probe.jar;C:\Users\Eric\Documents\NetBeansProjects\ModProj\dist\M.jar;C:\Users\Eric\Documents\NetBeansProjects\Java10App\build\classes --add-modules M,jdk.jshell --add-reads jdk.jshell=ALL-UNNAMED --module-path C:\Users\Eric\Documents\NetBeansProjects\Java10App\build\classes, main=main=org.netbeans.lib.jshell.agent.AgentWorker 63903, suspend=suspend=true, quote=quote=", vmexec=vmexec=java}
      | caused by: Failed remote launch: java.util.concurrent.ExecutionException: com.sun.jdi.connect.VMStartException: VM initialization failed for: C:\Program Files\Java\jdk-10.0.2\bin\java -classpath C:\Users\Eric\Downloads\incubating-netbeans-java-9.0-bin\netbeans\java\modules\ext\nb-mod-jshell-probe.jar;C:\Users\Eric\Documents\NetBeansProjects\ModProj\dist\M.jar;C:\Users\Eric\Documents\NetBeansProjects\Java10App\build\classes --add-modules M,jdk.jshell --add-reads jdk.jshell=ALL-UNNAMED --module-path C:\Users\Eric\Documents\NetBeansProjects\Java10App\build\classes -Xdebug -Xrunjdwp:transport=dt_shmem,address=javadebug2032,suspend=y org.netbeans.lib.jshell.agent.AgentWorker 63903 @ com.sun.jdi.CommandLineLaunch (defaults: home=C:\Program Files\Java\jdk-10.0.2, options=, main=, suspend=true, quote=", vmexec=java) – {home=home=C:\Program Files\Java\jdk-10.0.2, options=options=-classpath C:\Users\Eric\Downloads\incubating-netbeans-java-9.0-bin\netbeans\java\modules\ext\nb-mod-jshell-probe.jar;C:\Users\Eric\Documents\NetBeansProjects\ModProj\dist\M.jar;C:\Users\Eric\Documents\NetBeansProjects\Java10App\build\classes --add-modules M,jdk.jshell --add-reads jdk.jshell=ALL-UNNAMED --module-path C:\Users\Eric\Documents\NetBeansProjects\Java10App\build\classes, main=main=org.netbeans.lib.jshell.agent.AgentWorker 63903, suspend=suspend=true, quote=quote=", vmexec=vmexec=java}
      | caused by: com.sun.jdi.connect.VMStartException: VM initialization failed for: C:\Program Files\Java\jdk-10.0.2\bin\java -classpath C:\Users\Eric\Downloads\incubating-netbeans-java-9.0-bin\netbeans\java\modules\ext\nb-mod-jshell-probe.jar;C:\Users\Eric\Documents\NetBeansProjects\ModProj\dist\M.jar;C:\Users\Eric\Documents\NetBeansProjects\Java10App\build\classes --add-modules M,jdk.jshell --add-reads jdk.jshell=ALL-UNNAMED --module-path C:\Users\Eric\Documents\NetBeansProjects\Java10App\build\classes -Xdebug -Xrunjdwp:transport=dt_shmem,address=javadebug2032,suspend=y org.netbeans.lib.jshell.agent.AgentWorker 63903
      | caused by: VM initialization failed for: C:\Program Files\Java\jdk-10.0.2\bin\java -classpath C:\Users\Eric\Downloads\incubating-netbeans-java-9.0-bin\netbeans\java\modules\ext\nb-mod-jshell-probe.jar;C:\Users\Eric\Documents\NetBeansProjects\ModProj\dist\M.jar;C:\Users\Eric\Documents\NetBeansProjects\Java10App\build\classes --add-modules M,jdk.jshell --add-reads jdk.jshell=ALL-UNNAMED --module-path C:\Users\Eric\Documents\NetBeansProjects\Java10App\build\classes -Xdebug -Xrunjdwp:transport=dt_shmem,address=javadebug2032,suspend=y org.netbeans.lib.jshell.agent.AgentWorker 63903

       

      Some sanity checks:

      BOTH projects are using the same JDK (JDK10)

      I built/ created a jar for the Module project 

      Included is a screenshot of what happens

      Explanation of the screenshot:

      • the top JShell instance, was started by "Execute Java Shell" by right clicking on the Java10App (and it threw the stacktrace above)
      • the bottom JShell instance (Started from the ModProj project) was started by right clicking and "Execute Java Shell" works fine

      To minimize extraneous issues, neither project has anything extra in the modulepath/classpath

      there is only 1) module m in the ModProj project, and there is only 1) class m.AModClass

      To reproduce: (my names are in ())

      1) create a new "Java Modular Project" (ModProj) with Java9+VM
      2) create a new Module (M) in the modular project
      3) create a new (m) package
      4) create a new class (AModClass) in the (m) package
      5) update the "module-info.java" file to export the (m) package
      6) right click on "Execute Java Shell" on the (ModProj) project... verify it starts, verify you can call the code (AModClass)
      7) build the project

       

      8) create a new Java Application (Java10App) with Java 9+ runtime
      9) add a dependency to the existing Module (ModProj)
      10) add a class in the project (J10App) and verify it can access class (AModClass) in the module

      package apackage;
      import m.AModClass;
      public class J10App {
          public static void main(String[] args){
              System.out.println( AModClass.aStaticMethod() );
      {{    }}}
      }

      11) Right Click on the Java10App (project), select "Execute Java Shell"

      Attachments

        1. working_mod_jshell.png
          28 kB
          M. Eric DeFazio
        2. NetbeansShellError.png
          130 kB
          M. Eric DeFazio
        3. Module_path.png
          25 kB
          M. Eric DeFazio
        4. MavenJShellProjError.png
          113 kB
          M. Eric DeFazio
        5. Maven_JShell_Netbeans.png
          123 kB
          M. Eric DeFazio
        6. JShellConsole.png
          35 kB
          M. Eric DeFazio

        Activity

          People

            Unassigned Unassigned
            medefazio M. Eric DeFazio
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: