4

I'm looking for an interactive shell that I can bolt into a Java application for use in debugging and scripting. I'm not terribly interested in scripting in Java, so some more shell-like syntax would be fine, but I would like to be able to load and run 'external commands' on the fly (which would be Java .class files).

Unfortunately my platform is very limited in space --- double digits megabytes of heap space. As such languages like Groovy, Jython and JRuby are unsuitable.

I have found BeanShell, which looks okay, but it appears to have been dead for years and the syntax is rather cumbersome for command line use --- e.g. it would be nice to have stuff like 'help' typed in produce an error message, rather than silence.

Are there any other systems I should look at?

Edit: ...aaaaand I've just discovered that BeanShell2 requires reflection abilities that my platform doesn't have, and not even RetroWeaver can help me with this. I shall try BeanShell 1, but I'm not confident.

David Given
  • 13,277
  • 9
  • 76
  • 123
  • It's a Java 1.4 platform and all I can say about it more is that I can't talk about it right now. – David Given Apr 08 '11 at 20:58
  • 2
    How about Rhino, a Java-based implementation of JavaScript? http://jnb.ociweb.com/jnb/archive/jnbMar2001.html http://stackoverflow.com/questions/989017/scripting-in-java-javascript-from-a-server-side-class-file-in-java-1-5 – eee Apr 08 '11 at 21:06

3 Answers3

3

beanShell is just fine. It is done, not dead. And there seems to be a beanshell 2.0 branch.

Jochen Bedersdorfer
  • 4,093
  • 24
  • 26
2

You can take a look at Rhino.

Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically embedded into Java applications to provide scripting to end users. It is embedded in J2SE 6 as the default Java scripting engine.

Andy Turner
  • 137,514
  • 11
  • 162
  • 243
MAK
  • 26,140
  • 11
  • 55
  • 86
  • Javascript's still not really terribly good in a command line environment --- the syntax is too programming-language-y rather than command prompt-y; but it sounds a bit more plausible than BeanShell, so I shall check it out. Ta. – David Given Apr 08 '11 at 21:13
  • **rhino** have TAB completion on classes and methods!! – gavenkoa May 07 '13 at 06:52
  • Correct me if I am wrong, [jrunscript](http://docs.oracle.com/javase/7/docs/technotes/tools/share/jrunscript.html) is something very similar to this and it comes with Java 7. It's experimental and not well supported though. – Quazi Irfan Apr 19 '15 at 04:10
1

Cliche can expose user-specified methods that can be called during runtime.

buyandfold
  • 11
  • 1
  • 1