On 3/28/07, Leo User <leouser126@yahoo.com> wrote:
--- Michael Litherland <michael.litherland@gmail.com>
wrote:

> Even simpler - this seems to work:
>
> System.setProperty("python.path",
> "path/to/jythonlib.jar/Lib");
>
> Mike

Im going to be amazingly surprised if this will work
for the complete-jar solution, but Ill give it a shot.


It still would be nice if there were some simple clear
API methods that did the job instead of having to mess
around with environment variables and internal data
structures.  Its good that there are things that work
but everyone seems to be finding different ways of
doing the job.  Though there are some methods in
PySystemState that appear to do something to help,
add_classdir, etc.. .

leouser

This is the exact code I'm using:


        String[] paths = System.getProperty("java.class.path").
                split(System.getProperty("path.separator"));
        boolean foundLib = false;
        for (int i = 0; i < paths.length; i++) {
            if (paths[i].contains("jythonlib")) {
                System.setProperty("python.path", paths[i]+"/Lib");
                System.out.println("Using pythonlib at "+paths[i]+"/Lib");
                foundLib = true;
            }
        }
        if (!foundLib) {
            throw new RuntimeException("Required library jar not found!");
        }

If I comment out the setProperty line it fails - works otherwise.

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
>
=== message truncated ===




____________________________________________________________________________________
Sucker-punch spam with award-winning protection.
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html

-------------------------------------------------------------------------
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