Have you ever tried to use Java interactive with the upcoming JShell? If no, take a look into my former blog [1]. Today I’m going to write about using the  Java shell together with NetBeans.JShell offers a command to change the default editor. And you may change this to run NetBeans to edit code snippets. Using a NetBeans nightly (development) version, this might be set like this:

/set editor /home/mmueller/netbeans-dev-201606020002/bin/netbeans

You have to adapt the path to you current one. No, if you want to edit your code snippets using the /edit command invokes NetBeans. You’re able to edit the snippet, and on save, this will be executed within the Java shell. If you terminate NetBeans, the control is shifted back to jshell.

If NetBeans is already running when you invoke the shell’s edit command, then the snippet will be shown within NetBeans, but all changes are ignored. It seems, jshell observes file changes only, if the editor is launched from within jshell (this happens also to other editors like gedit).

The real cool stuff is to start jshell from the NetBeans terminal window:

jshell within NetBeans

(The screenshot is taken from Ubuntu. Using Windows, there is a display issue [2])

This allows you to exchange data by copy and paste within the NetBeans workspace. And after invoking /edit you can use the clipboard functions, too.

jshell with edit function invokedAnd hopefully one day, jshell is able to observe all changes in a repl-file, even if the editor is not spawned from jshell.


[1] blog.mueller-bruehl.de/netbeans/interactive-java-with-jshell

[2] netbeans.org/bugzilla/show_bug.cgi?id=257975