This page contains a reference to a prototype of a Java/Tcl interface. It allows you to execute simple Tcl scripts from Java, and implement Tcl commands as Java primitives.
The code was originally written by Patrick Naughton in November of 1994. I have made only minor changes since then.
Check out the main TclInterpreter class. To execute a Tcl script you have to create an instance of the TclInterpreter class and call the eval(String) method on it.
TclInterpreter tcl = new TclInterpreter(); tcl.eval("set a 33"); tcl.eval("puts [$a + 1]");To define a new Tcl primitive you have to subclass the TclInterpreter, define a method that takes an array of strings as an argument and returns a string and bind the method.
class MyTclInterpreter extends TclInterpreter { MyTclInterpreter() { bind("pair"); } String pair(String argv[]) { return "(" + argv[0] + "," + argv[1] + ")"; } }A slightly more elaborate example can be found in TclTest.java.
This is totally unsupported sample code. It is for your entertainment only.