Scripting languages that run in the Java Virtual Machine, like Jython or Groovy, always appealed to me, as I could keep using my Java libraries, but get prototyping done much faster.
Now, this week, a friend of mine pointed out jshell to me. This is an executable that has appeared in Java’s bin directory with Java 9. The amazing thing is, that it allows you to write Java code in a scripting manner, by simply starting it up with a classpath listing all the jars that you want to use!
Interactive scripting is all good and fine, for some quick show and tells, but why not go a bit further and code within a GUI? With this, jshell-scripting was born. A simple library that I put together over the weekend, which allows you to do scripting in two ways:
- embed a panel in your Swing applications (complete with syntax highlighting)
- use a release archive and place any additional jars in its lib directory, if you don’t want to write an actual application, but just script a bit
Here is a screenshot of example code that I got from the MOA blog and executed in the user interface (started up from the release archive):
Current version of the library is: 0.0.1