[ 
https://issues.apache.org/jira/browse/NETBEANS-1131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16577288#comment-16577288
 ] 

M. Eric DeFazio commented on NETBEANS-1131:
-------------------------------------------

First thing: Netbeans is a great tool, so please dont think Im just being a 
pain, (I'm more frustrated with the compatibility of the JPMS than netbeans, 
and the fact I was able to use JShell at all through the editor is a great 
addition and I enjoy using it) so thank you guys.

====

.. when I change the project (Java10App) and put the dependency on the 
ModulePath, and not the classpath, then the local class J10App doesnt compile.

FWIW I'm creating a library that I want to work in Java 8 or 9+ jar (And I also 
want the library to be usable in JShell) (modular or non-modular)

as it turns out I converted from IntelliJ to netbeans because (when I 
originally converted to Modules) I got Jshell to work the first time, and the 
"Execute Java Shell" option is super convenient

Anyways, thanks for being understanding, I think this is more an issue with the 
way the JPMS deals with libraries

Personally I wanted to avoid MAVEN because ... tooling bloat... but it sounds 
like (in order to get my library to work seemlessly in Java8 or 9+) I might 
have to do the OSGI hack as mentioned in Stephen Colebornes  blog 

http://blog.joda.org/2017/05/java-se-9-jpms-automatic-modules.html

(so that Java8 doesn't choke on parsing module-info)

 

> "Execute Java Shell" fails when in a non-modular project
> --------------------------------------------------------
>
>                 Key: NETBEANS-1131
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-1131
>             Project: NetBeans
>          Issue Type: Bug
>          Components: apisupport - Project
>    Affects Versions: 9.0
>         Environment: Product Version: Apache NetBeans IDE 9.0 (Build 
> incubator-netbeans-release-334-on-20180708)
> Java: 10.0.2; Java HotSpot(TM) 64-Bit Server VM 10.0.2+13
> Runtime: Java(TM) SE Runtime Environment 10.0.2+13
> System: Windows 10 version 10.0 running on amd64; Cp1252; en_US (nb)
> User directory: C:\Users\Eric\AppData\Roaming\NetBeans\9.0
> Cache directory: C:\Users\Eric\AppData\Local\NetBeans\Cache\9.0
>            Reporter: M. Eric DeFazio
>            Priority: Major
>         Attachments: NetbeansShellError.png
>
>
> 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"



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to