tclJBlend

tclJBlend 2.1

ABU 17-sep-2019 - released ver 2.1

tclJBlend (aka "Tcl-J-Blend" or "JBlend") is a new fork of TclBlend (See http://tcljava.sourceforge.net/ ), a Tcl extension that uses JNI to communicate with a Java interpreter.

Why a fork ?

The main goal of JBlend is to provide the same TclBlend command interface, with a single multiplatform package that can be installed and run on all the most popular platforms (Windows, Linux, MacOS), independently of the JVM installed on the target computer.

This means that - with no need of rebuild - you can install/copy JBlend on Win/Linux/Mac, and moreover, once installed, you are also free to change/upgrade the underlyng Tcl or JVM - again, with no need to rebuild JBlend .

To achieve this goal JBlend lost the TclBlend/Tcljava ability to act as a bidirectional bridge between a JVM and a Tcl interpreter; JBlend can be used only in one way, from Tcl to Java and not in the opposite direction. For many Tcl users like me, this is enough.

Changing the true nature of TclBlend/Tcljava, required radical changes over the original TclBlend code, not to mention the completely redesigned build procedures; hence the need of a fork: JBlend .

JBlend main features

  • JBlend provides the same TclBlend command interface (See the "Tcl/Java Package Commands" http://tcljava.sourceforge.net/docs/TclJava/contents.html )
  • JBlend is delivered as a single, multi-platform package, ready to run on all the most popular platforms: Windows (32/64 bit), Linux (32/64 bit) and MacOsX.
    • There are alternative distributions for specific targets (Win-x64, Linux-x64, MacOS-x64) embedding a JVM (from AdoptOpenJDK).
  • You can launch JBlend from any Tcl interpreter : "tclsh", "Wish" or even "tclkit" (See Note:1)
  • JBlend does not depend on a specific version of the installed Java runtime (JVM). (See Note:2)

-

  • Note:1) JBlend runs with Tcl 8.5.X and 8.6.X (and further ..) , *excluding* Tcl versions from 8.6.1 to 8.6.5 ( see Ticket https://core.tcl.tk/tcl/tktview?name=07d13d99b0 )
    Tcl 8.6.1 introduced a small change stopping extensions like tclblend. Tcl 8.6.6 re-enabled the support for such extensions
  • Note:2) JVM should be >= 1.4. (Tested with SUN/Oracle JVMs and AdoptOpenJDK).

Download

Prebuilt binary packages for Windows/Linux/MacOS are available at Sourceforge .

You can choose among an universal package (for Win/Mac/Linux) requiring an external JavaRuntimeEnvironment or a package for a specific platform bundled with an embedded JRE (OpenJDK).

  • JBlend-2.1.zip - JBlend for all the platforms (Win 32/64, Linux 32/64, MacOs) - requires an external JavaRuntimeEnviroment.
  • JBlend+JVM-win-x64-2.1.zip - JBlend with an embedded JRE (AdoptOpenJDK 1.8.xxx) for Windows x64
  • JBlend+JVM-linux-x64-2.1.zip - JBlend with an embedded JRE (AdoptOpenJDK 1.8.xxx) for Linux x64
  • JBlend+JVM-darwin-x64-2.1.zip - JBlend with an embedded JRE (AdoptOpenJDK 1.8.xxx) for MacOS x64

You can also download the JBlend development kit (only for developers/maintaners)

JBlend News : what's changed

  • ver 2.0.0a1 - Alpha-release
  • ver 2.0.0a2 - Alpha-release
  • ver 2.0b1 - Beta-release. Documentation for users and developers. Test suite included
    • Fixes serious bugs inherited by TclBlend 1.4.1:
      • BUGFIX: * Java resources cannot be found * Serious bug inherited by TclBlend 1.4.1 . Now fixed.
      • BUGFIX: * java::lock/unlock commands don't work with Tcl 8.6 - Now fixed
  • Added command java::isobject
  • Added command java::listify
  • Added global variable ::java::jvm (array) (the global array ::tcljava is deprecated)
  • ver 2.1 - easier installation, more dynamic configuration
    • JBlend binary distributions now come with new variants (JBlend+JVM*.zip is JBlend plus an embedded JVM)

How to use JBlend

What you need:

  • A Tcl interpreter, of course: (see above note-1 for valid versions)
    • tclsh or wish, or even tclkit
  • JBlend+JVM
    • Download the last public release, unzip it and place it as a subdirectory of one of the Tcl 'lib' directories.
      Alternatively, you can leave it 'out of Tcl', provided later you tell Tcl where TJB is placed.
    • If you downloaded a JBlend+JVM bundle, you are ready to run
    • otherwise you should tell JBlend where your JRE is located, or more precisely, where the Java dynamic library jvm.dll ( or libjvm.so (Linux) or libjvm.dylib (MacOS) ) is located. - See detailed instruction in JBlend/__JVMcfg.tcl

Starting from JBlend 2.1 there is no need to set the LD_LIBRARY_PATH environment variable.

Now you are ready to run ..

Running on Win/Mac/Linux

type the following Tcl commands

   # Uncomment and adapt the following line if JBlend is not placed in a directory
   #  referenced by the auto_path variable.
   #
   # lappend auto_path ...where-is-JBlend...
   #
   package require JBlend
    # create a Java object ( a java.lang.String ) 
   set x [java::new java.lang.String "Hello Tcl ! I'm a Java String"]
    # call the "toUpperCase" java-method
   set res [$x toUpperCase]
   puts $res
   ....

Running on Android (AndroWish)

ABU Please note that JBlend for Android comes with its own source/binary distribution.

No special precautions are needed since the runtime environment already has something like a JVM running when tclJBlend is loaded.

The same Tcl commands as in the previous examples can be used to make an upper case representation of a java.lang.String.

Note: the Java environment on Android does not fully support JavaBeans, thus Bean related functions of tclJBlend are not supported. Class loading seems to be different, too, and needs further investigation. As of 2019-02-25, support for tclJBlend in AndroWish is available in the source tree, but still WIP and thus to be considered alpha quality.

The JBlend workbench (only for JBlend maintainers)

Download the JBlend Development-Kit [L1 ], or better download the last version from the SourceForge SVN repository [L2 ]

Detailed instructions are within the bundled documentation. Here, just few quick notes:

  • You need a JDK, plus a GNU/C compiler.
  • On Windows you can download MingW , or you can use the free "MS Visual Studio 2005 Community Edition".

On windows

   cd ...\tclJBlend-devkit
   ms-build x32
   ms-build x64

On Unix (Linux/Mac or Windows+MingW)

   cd .../tclJBlend-devkit
   ./build.sh x32
   ./build.sh x64

By default intermediate results will be saved under the XBUILD subdirectory; XBUILD/tclJBlend contains the deliverable package. (If you use a shared disk for building, you can attach it to Win/Linux/Mac so that XBUILD/tclJBlend will collect all the native DLL/.so/.dylib so far built).

If you need to build a JBlend+JVM bundle, read the detailed instruction in tclJBlend-devkit/HowTO-AssembleJBlend+JVM.txt