Even simpler - this seems to work:

System.setProperty("python.path", "path/to/jythonlib.jar/Lib");

Mike

On 3/28/07, Leo User <leouser126@yahoo.com> wrote:
Wow,

that looks amazingly simple, Ill have to see if it
works for me and maybe I can ditch the special
importer Ive been using.

thanks!
leouser

--- Stefan Dupont-Christ < sdupont@gip.com> wrote:

> This is the way it worked for me:
>
> 1. after jar-ing up the Lib/ directory, it looks
> like this:
>
> > jar -tf jython-lib.jar
> META-INF/
> META-INF/MANIFEST.MF
> Lib/email/base64MIME.py
> Lib/email/Charset.py
> Lib/email/_compat21.py
> Lib/email/_compat22.py
> Lib/email/Encoders.py
> Lib/email/Errors.py
> [...]
>
> 2. jython-lib.jar needs to be in the CLASSPATH
>
> 3. in jython script I use:
>
> import sys
>
sys.packageManager.addJar("<path_to>/jython-lib.jar",
> 1)
> if not "<path_to>/jython-lib.jar/Lib" in sys.path:
> sys.path.append("<path_to>/jython-lib.jar/Lib")
>
> # now this should work
> import string, os
>
> Hope this helps
>
> --Stefan
>
> Michael Litherland wrote:
>
> > Hi,
> >
> > I've searched the documentation and the list
> archives as well as I
> > could and
> > though I've seen somewhat similar queries I
> haven't found any
> > solutions yet.
> >
> > I'm developing a Java application that needs to be
> easily
> > distributable and
> > doesn't require anything installed on the host
> system except Java 1.5 or
> > newer.  The Jython interpreter is embedded and
> used to validate and test
> > Jython code that the user can enter through the
> swing interface.  It
> > works
> > great right up until the user tries something
> like:
> >
> > import string
> > import re
> > #...
> >
> > Of course the issue is that when Jython is
> installed it know where the
> > Lib
> > directory is, but installing the Jython
> distribution on any of the host
> > machines is not an option (in fact this app will
> almost certainly only be
> > able to run as an applet or webstart).
> >
> > I've tried tricks like jarring up the Lib/
> directory and adding it to the
> > classpath which I should have guessed won't
> automagically work.  In the
> > Jython API the PathPackageManager looks promising,
> but I admit that I
> > can't
> > figure out how it ties into the interpreter.  It
> also appears that
> > python.path can help me out, but I don't think
> that just including the
> > Lib
> > dir and all those files is a very good solution
> (maybe not even possible
> > with webstart and applet).
> >
> > I don't mind interrogating a jar file containing
> all of the necessary
> > source
> > and fiddling with JarEntries and that fun stuff if
> there's a way that
> > I can
> > get access to the Jython standard imports in a Jar
> file.  I'm just hoping
> > someone's either done it before or can point me in
> the right direction in
> > the API docs.  It seems to me, also, that being
> able to distribute the
> > Lib
> > stuff in a jar would make a lot of people's lives
> easier.
> >
> > Thanks,
> > Mike
> >
>
>------------------------------------------------------------------------
> >
>
>-------------------------------------------------------------------------
> >Take Surveys. Earn Cash. Influence the Future of IT
> >Join SourceForge.net's Techsay panel and you'll get
> the chance to share your
> >opinions on IT & business topics through brief
> surveys-and earn cash
>
>http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> >
>
>------------------------------------------------------------------------
> >
> >_______________________________________________
> >Jython-users mailing list
> > Jython-users@lists.sourceforge.net
>
>https://lists.sourceforge.net/lists/listinfo/jython-users
> >
> >
>
>
> --
>
> Stefan Dupont-Christ
> _________________
>
> GIP Exyr GmbH
> Göttelmannstr. 17
> 55130 Mainz
>
> Tel: +49 (0) 6131 / 80 124 - 29
> Fax: +49 (0) 6131 / 80 124 - 24
>
> E-Mail: sdupont@gip.com
> Web: www.gip.com
>
> GIP Exyr GmbH
> Geschäftsführer: Dr. Bernd Reifenhäuser
> Handelsregister: HRB  6870 - Amtsgericht Mainz
>
>
>
-------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get
> the chance to share your
> opinions on IT & business topics through brief
> surveys-and earn cash
>
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Jython-users mailing list
> Jython-users@lists.sourceforge.net
>
https://lists.sourceforge.net/lists/listinfo/jython-users
>




____________________________________________________________________________________
TV dinner still cooling?
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users