Re: [tcljava-user] Adding a JACL 1.3.1 package
Brought to you by:
mdejong
From: Tom P. <tpo...@ny...> - 2004-06-29 21:42:13
|
On Mon, Jun 28, 2004 at 12:18:21PM -0700, Joe Weisblatt wrote: > I'd like to add some JACL commands, but I'm not really following how to > have it load without changing JACL sources. > If I hard-wire my command, it works fine. > But I'd like to do it just by adding a > tcl/lang/library/mypkg/pkgIndex.tcl, and I can't seem to get JACL to > find that file. > > I'm assuming the problem is that in the "package unknown" procedure, the > "glob" trying to find library/*/pkgIndex.tcl won't work on the auto_path > entry of "resource:/tcl/lang/library" because Java's getResource*() > methods won't do patterns. Is your package coded in Java as a Jacl extension, or simply a set of Tcl procedures? For Tcl-only packages, it should be easy enough to make a directory in your Jacl library (i.e., where the jacl.jar and tcljava.jar files exists), and drop in your Tcl package with an appropriate pkgIndex.tcl file. The trick is that you need to pass the TCLLIBPATH as a property when starting Jacl. I do this with a custom jaclsh. You should be able to do a similar scheme with a compiled Java extension, where your pkgIndex.tcl loads the extension. Or, you might be interested in tyring out my 'Hyde' package. Hyde lets you code Java extensions in your Tcl code, compiles and loads the bytecodes on the fly. Compilation is skipped if the Java code has already been compiled and stored in a bytecode cache file. Hyde itself is just a Tcl package that sits in my Jacl directory, /usr/local/lib/tcljava1.3.1/hyde-1.3 I've never formally released Hyde yet, but I can mail you a copy to try out if you are interested. I'm attaching my custom jaclsh script also. It assumes that Jacl is installed in the /usr/local tree; if not, it should be easy to modify, just adjust the paths for 'prefix' and 'JAVA'. It also can be linked as 'wisk', to start Jacl/Swank, if you have the Swank jar. -- Tom Poindexter tpo...@ny... http://www.nyx.net/~tpoindex/ #!/bin/sh # Wrapper script to start up Jacl # Do not edit this script unless it is called jaclsh.in. # configure takes jaclsh.in, substitutes the @xx@ # fields and creates jaclsh. # Author: Moses DeJong # Version: @(#)jaclsh.in 1.1 08/07/98 # # Copyright (c) 1998, 1999, 2000 Moses DeJong # All Rights Reserved, see license.terms for license information. # User environment variables that affect this script: # JAVA_HOME path to java home, in order to use alternate jvm # CLASSPATH additional classpaths # JACL_LIBRARY path to package library dir, defaults to Jacl jar library dir # JACL_FLAGS java jvm flags for jacl # JACL_PROPS extra -Dxxx=yyy properties to pass to jvm # Install prefix for jacl package, defaults to /usr/local prefix=/usr/local # Tcl/Java version number TCLJAVA_VERSION=1.3.1 # Directory where platform independent files live. This # includes the .jar files and any .tcl files XP_TCLJAVA_INSTALL_DIR=${prefix}/lib/tcljava${TCLJAVA_VERSION} # Directory where swank jar lives XP_SWANK_INSTALL_DIR=${XP_TCLJAVA_INSTALL_DIR} # Set jacl.tcllibpath from JACL_LIBRARY or default JACL_LIBPATH="-DTCLLIBPATH=${JACL_LIBRARY:-$XP_TCLJAVA_INSTALL_DIR}" # Add the .jar library files to the CLASSPATH # Check if running jaclsh or wisk, use the corresponding shell and classpath if [ `basename $0` = "wisk" ] ; then JACL_SHELL=tcl.lang.SwkShell JACL_CLASSPATH=/usr/local/java/jre/lib/rt.jar:${XP_SWANK_INSTALL_DIR}/swank.jar:${XP_TCLJAVA_INSTALL_DIR}/tcljava.jar:${XP_TCLJAVA_INSTALL_DIR}/jacl.jar else JACL_SHELL=tcl.lang.Shell JACL_CLASSPATH=/usr/local/java/jre/lib/rt.jar:${XP_TCLJAVA_INSTALL_DIR}/tcljava.jar:${XP_TCLJAVA_INSTALL_DIR}/jacl.jar fi # Fully qualified path name of JVM executable if [ "$JAVA_HOME" -a -x $JAVA_HOME/bin/java ] ; then JAVA=$JAVA_HOME/bin/java else JAVA=/usr/local/java/bin/java fi # The arguments to the JAVA command DEFAULT_JACL_FLAGS="-native -ms5m -mx22m" JACL_FLAGS="${JACL_FLAGS:-$DEFAULT_JACL_FLAGS}" # Run java with the args passed in from the calling environment # We must set the CLASSPATH env var instead of using the -classpath # argument because jacl might want to exec a program that also # depends on the CLASSPATH setting and Java can not export env vars CLASSPATH=${JACL_CLASSPATH}${CLASSPATH:+:${CLASSPATH}} export CLASSPATH # Allow other user specified properties to be passed via JACL_PROPS env variable exec ${JAVA} ${JACL_FLAGS} ${JACL_LIBPATH} ${JACL_PROPS} ${JACL_SHELL} ${1+"$@"} |