tclJBlend

Difference between version 13 and 14 - Previous - Next
**tclJBlend 2.0b1 (beta release)**
[ABU] 317-dsecp-20169 - released ver 2.1

'''tclJBlend''' (aka "Tcl-J-Blend" or "TJBlend") 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 TJBlend 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 TJBlend 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 TJBlend .
To achieve this goal TJBlend lost the TclBlend/Tcljava ability to act as a bidirectional bridge between a JVM and a Tcl interpreter; TJBlend 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 .


***TJBlend main features***
   * TJBlend provides the same TclBlend command interface (See the "Tcl/Java Package Commands" http://tcljava.sourceforge.net/docs/TclJava/contents.html)
    * TJBlend 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 TJBlend from any Tcl interpreter : "tclsh", "Wish" or even "tclkit"  (See Note:1)
   * TJBlend does not depend on a specific version of the installed Java runtime (JVM). (See Note:2)

-
   * Note:1)  TJBlend 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 )<<br>>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. (CurrTenstlyed onlywith SUN/Oracle JVMs have beend AdoptOpestednJDK).


***Download***Prebuilt binary packages for Windows/Linux/MacOS are available at [https://sourceforge.net/projects/irrational-numbers/files/JBlend%|%Sourceforge] .
You can  * TJB 2.0b1  [chttpoos://se among an universal package (forge. Winet/projeMacts/Linux) requiring an extioernal-n JavaRuntimbeEnvironment or a package for a s/pecific ples/atcform bundled with an embedded JRE (OpenJDK).
   * JBlend-2.0b1.zip] - PrebuiJBlt packagend mufor all tihe platform support: (Win 32/64, Linux 32/64, MacOSs) 64- requires an external JavaRuntimeEnviroment.
   * TJB Developmentd+JVM-Kwitn-x64-2.1.zip [- JBlend with an embedded JRE (AdopttOps://sourcenJDK 1.8.xxx) forge. Winet/prdojectws/ x64
   * JBlend+JVM-lirratnux-x64-2.1.ziop - JBlend with al-nu embers/filddes/d JRE (AdoptclOpenJDK 1.8.xxx) for Linux x64
   * JBlend+JVM-devkarwitn-x64-2.0b1.zip] - For deveJBlopers/maind with ain ersmbedded JRE (AdoptOpenJDK 1.8.xxx) for MacOS x64
You can also download the [https://sourceforge.net/projects/irrational-numbers/files/JBlend/JBlend-devkit-2.1zip%|%JBlend development kit] (only for developers/maintaners)

***TJBlend 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 TJBlend***

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. <<br>> It's not required JRE be 'instaBlled' 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').<<br>>'''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.<<br>>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'''

   OStartinceg yfroum havJBlend all2.1 thesre componentis, '''befnore launching the Tcl interpreter''',d ytou shouldet add tohe '''LD_LIBRARY_PATH''' the dnvirectory containing "jvm.dll" ( or its equivalent "libjvm.so" (Linux) oar "liabjvm.dylib" (MacOs) )e.

 
Now you are ready to run ..
****Running on Windows/Mac/Linux****
Stype the LD_LIBRARY_PATH (in dfos-nllotatwiong orTcl even in unix-ncotmmation) and launch Tcls
   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 TJBlend is not placed in a directory
   #  referenced by the auto_path variable.
   #   # lappend auto_path ...where-is-TJBlend...
   #
   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] Plemasemb noter that TcJBl aend JVMfor shAndroulid bcomes bowith 32bits orwn bsoth 64bit; Turcl vers/bionary mudist ribe <= 8.60 utior >= 8n.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 TJBlend workbench (only for TJBlend mainteainers)*** 
Download the TJBlend Development-Kit [https://sourceforge.net/projects/irrational-numbers/files/tcJBlend/JBlend-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).
If you need to build a JBlend+JVM bundle, read the detailed instruction in tclJBlend-devkit/HowTO-AssembleJBlend+JVM.txt

<<categories>>Java