On Fri, 15 Feb 2002 10:12:48 -0600
Dou...@gr... wrote:
: I've written a Java app that uses Jython to perform pattern matching with
: the 're' module. I guess that I didn't read the fine print because I was
: under the impression that all that I needed to make use of Jython was to
: ensure that jython.jar in my classpath. It appears to me now that I need
: to have Jython "installed" on any machine that will run my app. Is there a
: deployment shortcut that I'm missing here? What is the bare minimum that
: needs to be on a machine to call an embedded interpreter from Java code?
:
: This is the console error that I get when I point to the jython.jar file
: living someplace else other than Jython home.
: Exception in thread "main" Traceback (innermost last):
: File "<string>", line 1, in ?
: ImportError: no module named re
:
: I also noticed in the jython\lib directory that there are a number of class
: files that seem to have compiled that might pertain to the Jython calls
: that I have made. If they are related can I simply jar them up and deploy
: them - problem solved?
This will work if your application is on a local network server and you have write access to a "user" directory where jython's cache and at least two other files will be created.
1. Put the (original) Lib directory in a Jar file. From Jython-2.1's directory:
jar cf Py21Lib.jar Lib
I didn't put any .class file in this JAR file. Not sure if it would work.
2. Create a custom copy of "registry" (from you Jython-2.1's directory). Add your JAR file to the python.path key. Mine looks like this:
python.path = ./Jy21lib.jar/Lib;./macros
This assumes the Jy21Lib.jar will be in the same directory as the application. I also have a "macros" sub-directory under this one, where I put Jython scripts called from an embedded interpretor. Do not put Jy21Lib.jar in your CLASSPATH.
3. Make sure the jython.home key (below) is set to the directory (possibly the user home directory) containing your custom "registry" file.
On Win32 (and OS/2), I use the following .bat (or .cmd) file (for Java 1.1.8) to call the application. This script is in the same directory as the application. I create a "home" directory on a local drive. The file V21 is a dummy file only used to control the version of "registry" in this directory.
----
@ECHO OFF
IF NOT EXIST C:\HOME\* MD C:\HOME
IF EXIST C:\HOME\V21 GOTO S2
copy ORI\V21 C:\HOME
copy ORI\registry C:\HOME
:S2
IF EXIST C:\HOME\USGCFG.INI GOTO S3
copy ORI\usgcfg.* C:\HOME
:S3
jrew.exe -mx32m -Duser.home=C:\HOME -Dpython.home=C:\HOME -cp rmnjava.zip;rmnjlib.jar;swingall.jar;jython.jar rmn.Application
----
|