Re: [tcljava-user] "source resource:/" - howto?
Brought to you by:
mdejong
From: Tom P. <tpo...@ny...> - 2007-07-17 21:21:56
|
On Tue, Jul 17, 2007 at 12:11:37PM -0700, Mo DeJong wrote: > Patrick Finnegan wrote: > > What I would really like to do is dynamically load the procedure > > scripts as required in a "package require" type scenario. But > > "package require" is not supported under jacl > Package require is supported under Jacl. It is likely you are not using > the auto_path variable in the way it should, you can add > a path with a "resource:/" prefix to the auto_path and it should be > searched as expected. > > > so I thought about using auto_mkindex which seems to be supported > > under jacl. It seems to work with both directories and jar files. > > Great! > > > > 1. Directory. > > ******* > > wsadmin>auto_mkindex proclib > > > > then ................... > > > > set TCL_LIBRARY="directoryPath/proclib" > > > > Call jacl with the java -D option > > > > java bla bla bla "-DTCL_LIBRARY=%TCL_LIBRARY%" > > > This is not how TCL_LIBRARY should be used. In general, TCL_LIBRARY is > where Tcl/Jacl > find its own scripts. You should not use this for your application scripts. Jacl uses TCLLIBPATH, not TCL_LIBRARY to find packages. Jacl's init.tcl holds all of the clues: http://tcljava.cvs.sourceforge.net/tcljava/tcljava/src/jacl/tcl/lang/library/init.tcl?revision=1.7&view=markup I routinely use a modified 'jaclsh' that allows me to include Tcl packages that I place either in my Jacl installation dir (ones that are Jacl only), or specify other directories via an environment variable. For example: $ export JACL_LIBRARY=/usr/lib/tcllib1.7 $ jaclsh % # include my jacl based 'hyde' package % package require hyde 1.3 % # include log from tcllib % package require log 1.2 TCLLIBPATH is not split on ":", you have to space-separate directory entries. My Jacl installation : ls -CF /usr/local/lib/tcljava1.4.0 hyde-1.3/ itclsrc.jar jaclsrc.jar janinosrc.jar tcljava.jar tjc.jar itcl.jar jacl.jar janino.jar swank.jar tcljavasrc.jar tjcsrc.jar The hyde-1.3 directory has a valid pkgIndex.tcl file: package ifneeded hyde 1.3 "source [file join $dir hyde.tcl]" Note Tcllib1.7 has very few packages that require Tcl 8.0, I just used that as an example. Tcllib was installed from my Linux package system. Here is my 'jaclsh', a couple of notes first. - I copy swank.jar into my Jacl installation, and do 'ln -s jaclsh wisk'. That way, I can start Jacl or Swank from the same script, either by invoking 'jaclsh' or 'wisk'. - The following environment variables are recognized: JACL_FLAGS - JVM memory & other options JACL_LIBRARY - Tcl libraries to include JACL_PROPS - other JVM options, I use this for any "-Dxxxx=yyy" JACL_MAIN - if using a custom shell JAVA_HOME - which ever JVM I want to use --------------------------------------------------------------------- #!/bin/sh # Install prefix for jacl package, defaults to /usr/local prefix=/usr/local # Tcl/Java version number TCLJAVA_VERSION=1.4.0 # Directory where Jacl installation .jar files exists, and # other Jacl packages XP_TCLJAVA_INSTALL_DIR=${prefix}/lib/tcljava${TCLJAVA_VERSION} JACL_CLASSPATH=${XP_TCLJAVA_INSTALL_DIR}/tcljava.jar JACL_CLASSPATH=${JACL_CLASSPATH}:${XP_TCLJAVA_INSTALL_DIR}/jacl.jar JACL_CLASSPATH=${JACL_CLASSPATH}:${XP_TCLJAVA_INSTALL_DIR}/itcl.jar JACL_CLASSPATH=${JACL_CLASSPATH}:${XP_TCLJAVA_INSTALL_DIR}/tjc.jar JACL_CLASSPATH=${JACL_CLASSPATH}:${XP_TCLJAVA_INSTALL_DIR}/janino.jar # Fully qualified path name of JVM executable # Will be overridden if $JAVA_HOME is set and $JAVA_HOME/bin/java exists JAVA=/usr/local/java/bin/java # The arguments to the JAVA command DEFAULT_JACL_FLAGS="-ms5m -mx32m" JACL_FLAGS="${JACL_FLAGS:-$DEFAULT_JACL_FLAGS}" # If JACL_MAIN is set then use it as the name of the Java # class to execute. If it is not set, then use tcl.lang.Shell. # This provides an easy way to launch an alternative shell # without having to duplicate all the CLASSPATH and JAVA logic. if test "${JACL_MAIN}" = ""; then if [ `basename $0` = "wisk" ] ; then JACL_MAIN=tcl.lang.SwkShell JACL_CLASSPATH=${JACL_CLASSPATH}:${XP_TCLJAVA_INSTALL_DIR}/swank.jar else JACL_MAIN=tcl.lang.Shell fi fi # set CLASSPATH CLASSPATH=${JACL_CLASSPATH}:${CLASSPATH} export CLASSPATH # Fully qualified path name of JVM executable if [ -n "$JAVA_HOME" -a -x $JAVA_HOME/bin/java ] ; then JAVA=$JAVA_HOME/bin/java fi # Set TCLLIBPATH from JACL_LIBRARY and default JACL_LIBPATH="-DTCLLIBPATH=$JACL_LIBRARY $XP_TCLJAVA_INSTALL_DIR" exec ${JAVA} ${JAVA_FLAGS} "${JACL_LIBPATH}" ${JACL_PROPS} ${JACL_MAIN} ${1+"$@"} --------------------------------------------------------------------- -- Tom Poindexter tpo...@ny... |