Using JShell API on OS/X

Roy van Rijn roy.van.rijn at gmail.com
Mon Nov 16 16:36:50 UTC 2015


Dear JShell devs,

During Devoxx I had the chance to see Robert Field talk about JShell.
This talk is available here:
https://www.youtube.com/watch?v=jziVaht480w

At the end of the talk he showed us you can program against the JShell
just by doing things like:
JShell shell = JShell.create();
shell.eval(things);

I decided to try this and see if it is possible to create a simple
plugin for various tools. But when I downloaded the latest JDK9 EA
snapshot (b91) and do the simplest Hello World I quickly run into a
problem.

In my case, using IntelliJ IDEA the classpath in "java.class.path" has
the following entry added ":/Applications/IntelliJ IDEA
14.app/Contents/lib/idea_rt.jar". This causes a problem:

java -classpath
/Library/Java/JavaVirtualMachines/jdk1.9.0.jdk/Contents/Home...<snip>...l:/Applications/IntelliJ
IDEA 14.app/Contents/lib/idea_rt.jar
-Xbootclasspath:/Library/Java/JavaVirtualMachines/jdk1.9.0.jdk/Contents/Home/lib/modules/bootmodules.jimage
-Xdebug -Xrunjdwp:transport=dt_socket,address=roy.local:62661,suspend=y
jdk.internal.jshell.remote.RemoteAgent 62660

The error: Could not find or load main class IDEA

Apparently IntelliJ IDEA on OS/X will always cause the
"java.class.path" to have a space in it. Because of the space in the
path and they way ExecutionControl.jdiGo(int) uses that property.

A solution (on my side) might be to instruct IDEA to set the classpath
differently, enclosing it with double qoutes, but I think a lot of
people will run into this problem eventually? Does this need fixing in
JShell perhaps?

Roy


More information about the kulla-dev mailing list