**tclJBlend 2.0b1 (beta release)** [ABU] 3-dec-2016 '''tclJBlend''' (aka "Tcl-J-Blend" or "TJB") 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 TJB 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 TJB 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 TJB . To achieve this goal TJB lost the TclBlend/Tcljava ability to act as a bidirectional bridge between a JVM and a Tcl interpreter; TJB 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: TclJBlend . ***TJB main features*** * TJB provides the same TclBlend command interface (See the "Tcl/Java Package Commands" http://tcljava.sourceforge.net/docs/TclJava/contents.html) * TJB 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. * You can launch TJB from any Tcl interpreter : "tclsh", "Wish" or even "tclkit" (See Note:1) * TJB does not depend on a specific version of the installed Java runtime (JVM). (See Note:2) - * Note:1) TJB 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. (Currently only SUN/Oracle JVMs have been tested). ***Download*** * TJB 2.0b1 [https://sourceforge.net/projects/irrational-numbers/files/tclJBlend-2.0b1.zip] Prebuilt package multiplatform support: Win 32/64, Linux 32/64, MacOS 64 * TJB Development-Kit [https://sourceforge.net/projects/irrational-numbers/files/tclJBlend-devkit-2.0b1.zip] For developers/maintainers. ***TJB 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) ***How to use TJB*** What you need: * A Tcl interpreter, of course: (see above note-1 for valid versions) ** tclsh or wish, or even tclkit * A JVM: ** just a JRE, a JDK is not required. <
> It's not required JRE be 'installed' i.e. you don't need java.exe be in PATH, nor other special variable such as JAVA_HOME need to be set (nor the JRE need to be registered in the Windows Registry').<
>'''Please take note of the directory containing the entry point of the JVM: "jmv.dll" ( or its equivalent "libjvm.so" (Linux) or "libjvm.dylib" (MacOs) ).''' A big little WARNING: Don't mix 32/64 bit applications; Tcl and JVM should be both 32bit or both 64bit. * the TJB package ** 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. Once you have all these components, '''before launching the Tcl interpreter''', you should add to '''LD_LIBRARY_PATH''' the directory containing "jvm.dll" ( or its equivalent "libjvm.so" (Linux) or "libjvm.dylib" (MacOs) ). Now you are ready to run .. ****Running on Windows**** Set LD_LIBRARY_PATH (in dos-notation or even in unix-notation) and launch Tcl DOS> set LD_LIBRARY_PATH="c:\MYJRE\bin\client;%LD_LIBRARY_PATH%" DOS> tclsh then type the following Tcl commands # Uncomment and adapt the following line if TJB is not placed in a directory # referenced by the auto_path variable. # # lappend auto_path ...where-is-TJB... # 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 .... Remember that Tcl and JVM should be both 32bit or both 64bit; Tcl version must be <= 8.60 or >= 8.6.6 ****Running on Linux**** Set LD_LIBRARY_PATH and launch Tcl sh> LD_LIBRARY_PATH=".../jre1.7.0_80/lib/amd64/server:$LD_LIBRARY_PATH" sh> export LD_LIBRARY_PATH sh> tclsh then type the (same) Tcl commands # Uncomment and adapt the following line if TJB is not placed in a directory # referenced by the auto_path variable. # # lappend auto_path ...where-is-TJB... # 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 .... '''Note:''' it is important to set LD_LIBRARY_PATH *before* launching Tcl ; setting env(LD_LIBRARY_PATH) from inside Tcl would be easy, but it doesn't work ! ****Running on MacOs**** Set LD_LIBRARY_PATH and launch Tcl sh> ## be careful of white spaces ! sh> LD_LIBRARY_PATH=/Library/Internet\ Plugins/JavaAppletPlugin.plugin/Contents/Home/lib/server:$LD_LIBRARY_PATH sh> export LD_LIBRARY_PATH sh> tclsh then type the (same) Tcl commands # Uncomment and adapt the following line if TJB is not placed in a directory # referenced by the auto_path variable. # # lappend auto_path ...where-is-TJB... # 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 .... '''Note:''' it is important to set LD_LIBRARY_PATH *before* launching Tcl ; setting env(LD_LIBRARY_PATH) from inside Tcl would be easy, but it doesn't work ! ****Running on Android ([AndroWish])**** 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 TJB workbench (only for TJB mainteners)*** Download the TJB Development-Kit [https://sourceforge.net/projects/irrational-numbers/files/tclJBlend-devkit-2.0b1.zip], or better download the last version from the SourceForge SVN repository [https://sourceforge.net/p/irrational-numbers/code/HEAD/tree/pkgs/tclJBlend-devkit] 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). <>Java