Version 13 of TclBlend

Updated 2005-10-11 08:59:06

http://tcljava.sourceforge.net/ is the home of Tcl Blend. Tcl Blend is a Tcl package that provides access to Java classes from Tcl. Tcl Blend is implemented using JNI. Tcl Blend is production ready software, it is stable enough to be used in production systems on a daily basis.

Jacl and TclBlend are both implementations that make it easy to use Tcl scripting on the Java platform. The Tcl/Java project provides mailing lists [L1 ], online documentation [L2 ], and a bug reporting interface [L3 ].

Links to a number of Jacl and Tcl Blend related articles are also available [L4 ].

For help building Jacl under Windows, see Building TclBlend with msys_mingw.


One comp.lang.tcl poster reports satisfying light-duty use of JDBC with TclBlend.


LV Anyone know of an example of a good use for tclblend - a place where someone has used tclblend to solve a problem? Something that could act as a demo perhaps.

JR I'm using it to add a JMS listener into tclhttpd. The threading models and java's lack of an event loop make it a bit tricky but it works well enough for my needs (and is way easier than doing it in java).


See also


Use of TclBlend to put a JMS message on a remote IBM MQ Windows queue using MQ JMS classes.

 ###########################################################

 # Connect to MQ listener and put message on the queue.

 ###########################################################

 puts "\n executing [info script]\n"

 # make script drive independent.

 set drive [lindex [file split [info nameofexecutable]] 0 ] 

 puts "\n proclib = $drive/scripts/TCL/proclib"


 ########################################################  

 # Source packages. 

 ########################################################  

 package require java

 ######################################

 # Proc - put message. 

 ######################################

 proc putMSG { QManager CCSID channel hostname queueName port traceFile msg } {

    puts "\n putMSG \n"

    # import required classes 
    java::import com.ibm.mq.jms.MQQueueConnectionFactory
    java::import com.ibm.mq.jms.services.ConfigEnvironment
    java::import com.ibm.mq.jms.JMSC
    java::import com.ibm.mq.jms.MQQueueSession
    java::import com.ibm.mq.jms.MQQueueSender

    # instanciate MQQueueConnectionFactoryI object.

    set MQQueueConnectionFactoryI [ java::new MQQueueConnectionFactory ]

    # set MQQueueConnectionFactory instance methods.

    $MQQueueConnectionFactoryI setQueueManager         $QManager
    $MQQueueConnectionFactoryI setPort                 $port
    $MQQueueConnectionFactoryI setHostName             $hostname
    $MQQueueConnectionFactoryI setChannel              $channel
    $MQQueueConnectionFactoryI setCCSID                $CCSID
    $MQQueueConnectionFactoryI setUseConnectionPooling true
    $MQQueueConnectionFactoryI setTransportType        [ java::field JMSC MQJMS_TP_CLIENT_MQ_TCPIP ]    

    # set tracing on.

    java::call ConfigEnvironment start

    puts "Creating a Connection...................\n"

    set connectionI [ $MQQueueConnectionFactoryI createQueueConnection ]

    puts "Starting the Connection.................\n"

    $connectionI start

    puts "Creating a Session......................\n"

    set transacted      false 
    set autoAcknowledge [ java::field MQQueueSession AUTO_ACKNOWLEDGE ]
    set sessionI        [ $connectionI createQueueSession $transacted $autoAcknowledge ]

    puts "Creating a queue......................\n"

    set queueI         [ $sessionI createQueue $queueName ]

    puts "Creating a queue sender ......................\n"

    set queueSenderI  [ $sessionI createSender $queueI ] 

    puts "Sending the message to..[ $queueI getQueueName ]\n" 

    puts "Creating a TextMessage........................\n"

    set outMsgI [ $sessionI createTextMessage ]

    $outMsgI    setText $msg

    puts "Sending TextMessage \"$msg\" \n"

    $queueSenderI send $outMsgI

    puts "Closing QueueSender........................\n"

    $queueSenderI close 

    puts "Closing Session............................\n"

    $sessionI close 

    puts "Closing Connection.........................\n"

    $connectionI close 

 }

 ######################################

 # Main Control.

 ######################################

 # build tcl classpath

 append x $drive/IBM/WebSphereMQ/Java/lib/com.ibm.mq.jar\;

 append x $drive/IBM/WebSphereMQ/Tools/Java/base\;

 append x $drive/IBM/WebSphereMQ/Java/lib/com.ibm.mqjms.jar\;

 append x $drive/IBM/WebSphereMQ/Tools/Java/jms\;

 append x $drive/IBM/WebSphereMQ/Java/lib/com.ibm.mqbind.jar\;

 set env(TCL_CLASSPATH) $x

 puts "\nTCL_CLASSPATH = [ array get env TCL_CLASSPATH ]\n"

 set traceFile    $drive/IBM/WebSphereMQ/Errors/mqTrace.txt

 set reportFile   $drive/reports/notify/mqConnect.txt

 set reportFileId [ open $reportFile w ] 

 set QManager  QM1

 set CCSID     819

 set channel   AAAAAAA.BBB.CCCCCC

 set hostname  moonbase1

 set queueName ABC.DD.EEEE.1234.FFFFFFFF

 set port      1414

 set msg       "Watson, please come here. I want you."

 putMSG $QManager $CCSID $channel $hostname $queueName $port $traceFile $msg

Category Java