[tcljava-user] evalFile & package require: How to execute a tcl file that starts a tcl based app?
Brought to you by:
mdejong
From: Patrick F. <pfi...@oz...> - 2007-03-19 12:07:00
|
There are three ways of using Tcl with JACL. 1. Tcl intepreter written in Java - JACL. JACL is a cut down version of Tcl where Tcl commands have been written in Java rather than C. e.g the "puts" command looks like: package tcl.lang; /** * This class implements the built-in "list" command in Tcl. */ class ListCmd implements Command { /** * See Tcl user documentation for details. */ public void cmdProc(Interp interp, TclObject argv[]) throws TclException { TclObject list = TclList.newInstance(); try { for (int i = 1; i<argv.length; i++) { TclList.append(interp, list, argv[i]); } interp.setResult(list); } catch (TclException te) { list.release(); throw te; } } } None of the non core Tcl extensions have been ported to Java so non core packages such as Tk(wish) Expect, HTTP, SOAP etc are not available in JACL and JACL scripts are limited to using the basic Tcl command set which in the case of some commands is still at version 8.0. So it's very limited especially when you can't run TK apps. It's package require command is architected to search jar files in the java classpath. So it's difficult if not impossible to port an existing Tcl application to JACL without a rewrite of the app. No can do ---> "The whole purpose of this exercise is to remove the need for a seperate Tcl interpreter installation by using the one within Jacl". 2. Tcl intepreter written in C that loads it's own JVM using JNI. This is essentially loading a Java runtime under a C runtime. It's designed for Tcl programmers that want to work with Java and supports all Tcl packages including Tk(wish). See patrickfinnegan.com for a description. 3. Tcl intepreter written in C loaded into the JVM. This is what you want and it should be possible to load Tclblend into the JVM but I have not tried it as I do most of my work with JACL and TclBlend --> Java. There is an excellent description of this type of architecture at: http://www.ensta.fr/~diam/tcl/online/Using_Tcl_in_Java-20010106.html#7 You can grap the TclBlend binary from patrickfinnegan.com Sent with SnapperMail www.snappermail.com |