Tcl Blend

This page is left around for historical reasons only.

As of November, 2010, the Ptolemy project is using a slightly customize version of Jacl as part of the Ptolemy test suite. For details, see http://ptolemy.berkeley.edu/ptolemyII/ptIIlatest/ptII/doc/install_index.htm

Remote Places to go

  • Scriptics Jacl and Tcl Blend page (Dead Link, try Archive.org)
  • Tcljava Mailing List Archives: www.egroups.com - www.mail-archive.com
  • Tutorial given at the Tcl/Tk conference, 9/16/98 Tcl and Java Programming: Practice and Pitfalls - Tutorial Notes
  • The release notes for Sun's Java Embedded Server state that Jacl is included as an unsupported feature (Dead Link, try Archive.org)
  • Cameron Laird's personal notes on Jacl and Tcl Blend (Dead Link, try Archive.org)
  • Steve Ball's chapter about Tcl Blend and Jacl from a forthcoming book.
  • The ICEM CFD Compiler may some day generate Java Byte Codes.
  • Java Resources
  • www.javasoft.com
  • Java Developers Connection: http://www.javasoft.com/jdc - This is free to join, and a good place to search for information about JNI bugs.
  • JDK1.2 JNI Enhancements: http://java.sun.com/products/jdk/1.2/docs/guide/jni/index.html - Includes the JNI1.1 Specification and a FAQ
  • Javasoft JNI Tutorial http://www.javasoft.com/docs/books/tutorial/native1.1/index.html
  • Local Places to go

  • Jacl and Tcl Blend Developer's Downloads
  • Notes about Using Tcl Blend and Jacl
  • Version Information
  • Tcl Blend Exceptions
  • Hints about java.lang.System.out.println and Tcl Blend
  • Jacl Applets
  • Tcl Bean
  • Troubleshooting
  • Tcl and Java Performance (Somewhat out of date)
  • Article about Jacl/JPython/Javascript performance
  • TclJava page (out of date)
  • Contents

  • What is Tcl Blend?
  • What is This Page?
  • Tcl Blend Documentation
  • TclJava Mailing List
  • Todo
  • Using Tcl Blend under Windows
  • Using Tcl Blend under Solaris
  • Ports to other Platforms
  • Using Jacl under Windows
  • Using Jacl under Solaris

  • What is Tcl Blend?

    Tcl Blend is Sun's Tcl/Java interface that works with Tcl8.0 and JDK1.1. and JDK1.2 See the Jacl and Tcl Blend page for more information.

    What is This Page?

    This page consists of my notes about using Tcl Blend.

    Tcl Blend Documentation

    The Tcl Blend documentation is in tclBlend1.1/doc/html/contents.htm
  • Tcl Blend documentation: Scriptics Jacl and Tcl Blend Docs

  • TclJava Mailing List

    The TclJava mailing list is for issues involving Tcl and Java. To subscribe to the list, send email to tcljava-request@tclconsortium.org with the subject subscribe

    To send messages to the list, send mail to tcljava@tclconsortium.org

    Note that the tcljava list is not run by majordomo, so the usual majordomo commands will not work

    There are two archives: Tcljava Mailing List Archives: www.egroups.com - www.mail-archive.com


    Todo

  • Use GNU regex classes
  • Jacl clock
  • Linux port
  • Remove the bean
  • Remove green.c, purify rules
  • Add Jacl shell to demos
  • java try command
  • Start fixing the documentation so it works with javadoc?
  • Better Java Installer for Jacl
  • Using Tcl Blend under Windows

    1. If you have not yet done so, download the Sun JDK for Windows from http://java.sun.com/products/jdk/1.1/download-jdk-windows.html Note that Tcl Blend 1.1 will only work with the Sun JDK, it will not work with the Microsoft JDK. Tcl Blend 1.1 will work with either JDK1.1.6 or later, including JDK1.2fcs.
    2. Install the JDK so that it is in the C: top level directory, so that C:\jdk1.1.7 is created.
    3. Download and install Tcl 8.0 for Windows. Tcl Blend requires Tcl8.0 or later. Tcl Blend will not work with Tcl8.1a.
    4. Install the TclTk8.0 distribution so that is installed in C:\Program Files\Tcl
    5. Download the Microsoft Tcl Blend binaries from Scriptics Jacl and Tcl Blend Download page
    6. Install the Tcl Blend distribution so that the documentation and demos are is installed in. C:\Program Files\Tcl\TclBlend1.1. The installer will automatically install the .jar files and the .dll files into C:\Program Files\Tcl\lib\tclblend1.1.
    7. To test Tcl Blend, go to the Start menu, choose the Tcl menu, then choose the Wish icon.
      Load the Tcl Blend package with
      package require java
      
      Then type:
      java::call System getProperty "java.version"
      
      You should get back the version of the JDK that Tcl Blend is using.
    8. If you always want to load the java package, you can add the package require java line to your wishrc.tcl or tclshrc.tcl file so that java Tcl package is loaded each time you start up wish or tclsh.

      Under Windows, when Tcl sees a tilde (~), it uses the value of the HOME environment variable to find the user's home directory. If HOME is not set, then HOMEDRIVE and HOMEPATH are used.

    9. HOMEDRIVE refers to the drive your home directory is on,
    10. HOMEPATH is the pathname to your home directory on that drive.
    11. Usually, HOMEDRIVE and HOMEPATH are set when your account is created. If neither HOMEDRIVE or HOMEPATH is used, then c:\ is used.
    If you have problems, see Problems under Windows

    Using Tcl Blend under Solaris

    1. If you have not yet done so, download the Sun JDK from www.javasoft.com. Note that Tcl Blend 1.1 will only work with the Sun JDK1.1.6 and later, including JDK1.2fcs.
    2. Install the JDK and add the bin directory to your path in your .cshrc. If you install the JDK in /opt/jdk1.1.6, then you would add /opt/jdk1.1.6/bin to your path.
    3. Install Tcl on your system. The easiest way is to download the source from http://www.scriptics.com/software/8.0.html and install it.
    4. Download the Solaris Tcl Blend binaries from Scriptics Jacl and Tcl Blend Download page
    5. Add the bin directory where you installed Tcl to your path.
    6. Untar the Tcl Blend tar file. If you can become root, then /opt or /usr/local is a good place to run untar Tcl Blend.
    7. Read the instructions in tclBlend1.0/unix/README.
    8. Add the tclBlend1.0/unix directory to your LD_LIBRARY_PATH
    9. Add the JDK lib/sparc/native_threads directory to your LD_LIBRARY_PATH
    10. For example, if both Tcl Blend and Java were installed in /opt, you would add the following to your .cshrc
      setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/opt/tclBlend1.0/unix
      setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/opt/jdk1.1.6/lib/sparc/native_threads
      
      
    11. Set your LD_LIBRARY_PATH variable and update your path by sourcing your .cshrc, then start up tclsh8.0.
    12. Tcl Blend is a Tcl package, so add the Tcl Blend installation directory to the auto_path Tcl variable. Assuming you've installed Tcl Blend in /opt, you would type the following in to the Tcl prompt:
      lappend auto_path /opt/tclBlend1.0
      
    13. To load the Tcl Blend package, type package require java
    14. To test Tcl Blend, type
      java::call System getProperty "java.version"
      
      you should get back the version of the JDK you are running.
    15. Here's an example that combines the steps above and shows how to set the environment up:
      cxh@carson 58% set path = (/usr/sww/tcl-8.0p2/bin /usr/ucb /usr/bin)
      cxh@carson 59% setenv LD_LIBRARY_PATH /opt/jdk1.1.6/lib/sparc/native_threads:/opt/tclBlend1.0/unix
      cxh@carson 60% tclsh
      % lappend auto_path /opt/tclBlend1.0
      /usr/sww/tcl-8.0p2/lib/tcl8.0 /usr/sww/tcl-8.0p2/lib /opt/tclBlend1.0
      % package require java
      1.0
      % java::call System getProperty "java.version"
      1.1.6
      % 
      
    16. If you will always be running Tcl Blend, you can add the
      lappend auto_path /opt/tclBlend1.0
      package require java
      
      lines to ~/.tclshrc and/or ~/.wishrc so that Tcl Blend is loaded each time you start tclsh or wish. If you add these lines, you may also want to add a puts to remind you that the Tcl Blend package is being loaded.
    If you have problems, see Problems under Solaris

    Ports to other Platforms

    Currently, Tcl Blend runs under Windows 95/NT and Solaris 2.x

    JDK1.1 and Java Native Invocation (JNI) are both required to build Tcl Blend.

    Note that under Solaris, Tcl Blend requires the native threads pack. I believe that this was necessary to work around a bug http://java.sun.com/nav/read/Tutorial/native1.1/implementing/invo.html says

    Limitations of the Invocation API in JDK1.1

    As mentioned above, there are a number of limitations of the Invocation API implementation in JDK1.1.

    The user-level Java thread implementation on Solaris requires the Java VM to redirect certain Solaris system calls. The set of redirected system calls currently includes read, readv, write, writev, getmsg, putmsg, poll, open, close, pipe, fcntl, dup, create, accept, recv, send, and so on. This may cause undesirable effects on a hosting native application that also depends on these system calls.

    In a post to comp.lang.tcl, Scott Stanton wrote:
    TclBlend is not dynamically loadable into tclsh using green threads. You have to build a special version of tclsh that initializes the Java VM before Tcl does any I/O operations. I would recommend that you apply the Solaris patches and use the native threads version if you can.

    HP Tcl Blend Port

    ON 11/15/98, http://www.hp.com/esy/technology/jdk/products/os11pr112.html said:
    This release for HP-UX 11.00 includes the addition of a second virtual machine which permits you to use kernel threads to implement Java threads thus allowing a single Java application to make use of additional processors in a multiprocessor machine. This new virtual machine is the default virtual machine. The other virtual machine does not make use of kernel-threads to implement Java threads--it uses a portable, user-level "green threads" package. You have the option of using either virtual machine, and may want to try both to see which provides the best performance for your application. For more information, see (http://www.hp.com/esy/technology/jdk/products/document.html) Kernel Threads for HP-UX 11.00.
    It looks like the 1.1.6 port for HP-UX 10.20 does not support "Kernel" or native threads, /opt/java/PA_RISC/native_threads does not exist, but /opt/java/PA_RISC/green_threads does.

    Linux Tcl Blend Port

    As of 11/15/98, the Linux JDK1.1.7a port at http://www.blackdown.org/java-linux.html apparently supports Native Threads, though we have not tried it.

    http://www.blackdown.org/java-linux/rel/117/v1a/README-1.1.7v1a.html (Dead Link, try Archive.org) says:

    Native Threads support
    ----------------------
    
    Starting with the 1.1.7 v1a port of the Java Virtual Machine, we have
    added native thread support.  Traditionally, the JVM used user based
    threads, also known as "green" threads.  Native threads, on the other
    hand, use the operating system to do the task switching.
    
    Native threads are thus a benefit in multi-processor (SMP) systems
    and they tend to make native method invocation support easier to
    deal with.
    
    Native threads do have some limitations relative to green threads.
    They require more overhead and are limited to the number of processes
    your Linux kernel supports.
    
    Native thread support is new as of 1.1.7 v1a due to the wonderful
    effort of Phill Edwards.
    
    To install the native threads package, you need to first download
    the JDK, JRE, RT and install that.  Next, you need to get the matching
    native threads package and install that into the same location.
    Finally, to use the native threads version of the JVM, you need
    to set the THREADS_FLAG environment variable to "native"
    
    Note, that while the native threads support works very well and has
    been tested by the Java-Linux porting team, it should still be viewed
    as "beta" code as it has not had the extended testing that the
    green threads code has.
    
    Also, at this time there is no native threads support for libc5 systems.
    Only glibc based Linux systems.
    

    Digital Unix Tcl Blend Port

    JDK1.1.4 for Digital Unix supports Java Native Interface (JNI) and POSIX Threads.

    Tcl Blend 1.1b1 can compile under Digital Unix V4.0B with JDK1.1.4. However, starting up is tricky, since it requires that we set the CLASSPATH and load libjava.so first:

    cxh@bips 358% setenv CLASSPATH /usr/lib/classes.zip
    cxh@bips 359% tclsh8.0
    % load /usr/shlib/libjava.so
    couldn't find procedure Java_Init
    % package require java
    1.1
    % 
    
    If I don't have my CLASSPATH set, I get:
    cxh@bips 367% unsetenv CLASSPATH
    cxh@bips 368% tclsh8.0
    % load /usr/shlib/libjava.so
    couldn't find procedure Java_Init
    % package require java
    libjava.so: couldn't find procedure Java_Init
    Unable to initialize threads: cannot find class java/lang/Thread
    SIGILL    4*   illegal instruction
        si_signo [4]: SIGILL    4*   illegal instruction
        si_errno [0]: Error 0 occurred.
        si_code [1]: ILL_ILLOPN [addr: 0x0]
    
    Full thread dump:
    Abort process
    cxh@bips 369% 
    
    If I don't do the first load, I get:
    cxh@bips 376% setenv CLASSPATH /usr/lib/classes.zip
    cxh@bips 377% tclsh8.0
    % package require java
    Loading 'libtclblend.so' failed:
     couldn't load file "libtclblend.so": dlopen: Unresolved symbols
    % 
    
    I poked around and if I build libtclblend.so with:
    ld javaCmd.o  javaIdle.o  javaInterp.o  javaObj.o  javaList.o  javaNotifier.o  javaTimer.o  javaUtil.o  tclResult.o  unixNotifier.o -o libtclblend.so -shared -ljava -L/users/cxh/tcltk/lib -ltcl8.0 -lc
    
    Then I don't have to do the first load

    To run the test suite, I had to edit pkgIndex.tcl and add

       if [catch {load /usr/shlib/libjava.so} errMsg ]  {
           puts "libjava.so: $errMsg"
       }
    
    Most of the test suite passes, though the log shows that there are some failures.

    Using Jacl under Windows

    1. If you have not yet done so, download the Sun JDK from. www.javasoft.com. Jacl does not require the Sun JDK, but Tcl Blend does, so if you plan on experimenting with Tcl Blend, you will need the Sun JDK.
      If the JDK is installed at c:\jdk1.1.6, then add c:\jdk1.1.6\bin is in your path.
    2. Download the Windows Jacl installer from the Scriptics Jacl and Tcl Blend Download page http://www.scriptics.com/software/java.html and install Jacl Unfortunately the jacl.bat script has a problem with path names that have spaces in them, so do not install Jacl in C:\Program Files\Jacl1.0.
    3. Read the README file.
    4. To start Jacl, start up a MS-DOS Command prompt and type
      set CLASSPATH=%CLASSPATH%;C:\jacl1.0\jacl.jar
      java tcl.lang.Shell
      
    5. Below is an example:
      Microsoft(R) Windows NT(TM)
      (C) Copyright 1985-1996 Microsoft Corp.
      
      c:\users\cxh>set CLASSPATH c:\jacl1.0\jacl.jar
      Environment variable CLASSPATH not defined
      
      c:\users\cxh>set CLASSPATH=c:\jacl1.0\jacl.jar
      
      c:\users\cxh>java tcl.lang.Shell
      % java::call System getProperty "java.version"
      1.1.6
      %
      
    Problems:
  • package require java fails with can't find package java
    Be sure that auto_path is set, for example: lappend auto_path /opt/tclBlend1.0. An alternative is to install Tcl Blend in the Tcl library directory.

  • Using Jacl under Solaris

    1. If you have not yet done so, download the Sun JDK from. www.javasoft.com. Jacll does not require the Sun JDK, but Tcl Blend does, so if you plan on experimenting with Tcl Blend, you will need the Sun JDK.
      If the JDK is installed at /opt/jdk1.1.6, then add /opt/bin is in your path.
    2. Download the Jacl Binary release from the Scriptics Jacl and Tcl Blend Download page http://www.scriptics.com/software/java.html and untar the release.
    3. Read the INSTALL.txt file.
    4. To start Jacl, set your CLASSPATH and go.
      cxh@carson 1% setenv CLASSPATH /opt/jacl1.0/jacl.jar
      cxh@carson 2% java tcl.lang.Shell
      % java::call System getProperty "java.version"
      1.1.6
      % 
      
      Note that if you set your CLASSPATH in your .cshrc, then you may have mysterious problems with Netscape and other applications. One way to avoid this is to set up an alias in your .cshrc:
      alias jacl java -classpath /opt/jacl1.0/jacl.jar:/opt/jdk1.1.6/lib/classes.zip tcl.lang.Shell
      
      Then you can type jacl to start up Jacl.
    If you get something like:
    cxh@carson 71% /opt/jdk1.1.6/bin/java tcl.lang.Shell
    Can't find class tcl.lang.Shell
    
    Then be sure that your CLASSPATH is set properly.

    Last updated: %G%

    cxh at eecs