javajava-9jshell

Can the Java 9 jshell be used to run code in another JVM?


Java 9 has a read-eval-print loop for Java, called jshell. I've seen it work in it's basic mode, from the command line. Can it also be used in a remote process? In other words, can I connect to another Java process and enter code snippets to run within that runtime? This would be a nice way to change configuration state in an app server without having to write an admin tool with a UI.


Solution

  • The simple answer is no, there is no way to attach jshell to a running Java process. jshell is a standalone app that runs in its own JVM.