03.06.2013 12:37, simon nasrallah kirjoitti:
Hi ,
This may be of interest to someone so I thought I'd post some info
on how I got Jython in a Java project running over JNLP a.k.a Webstart .
I've been running Jython via Webstart for a few years now.
My recipe is this:
1. Sign the regular jython jar file
2. Package and sign the Lib directory contents
3. (Optionally compile and) package and sign your own app

No pyclasspath managing is required. Of course you can combine 1. and 2. into a single archive if you want.

I'm sure I've made some classic mistakes, but it does work.

One of the many problems I had was adding a path to my *.py files over JNLP
the python.path I had in my project worked fine locally but when using
it in a sandboxed webstart environment I had to do quite a few extra steps.

1. found I had to explode the jython.jar into the distribution and then just jarsign the one jar
2. had to add "__pyclasspath__/dsi" to find my *.py files (see below)
3. had to add "__pyclasspath__/Lib" to find Jython's distro *.py files (see below)


code snippet to set pyclasspath from
https://github.com/snasrallah/DiskSpaceInformer/blob/master/src/dsi/Utils.java
     
        String path1 = "__pyclasspath__/Lib";
        String path2 = "__pyclasspath__/dsi";
        Properties props = new Properties();

        if (System.getProperty("os.name").startsWith("Win")){
            props.setProperty("python.path", path1 + ";" + path2);
        } else{
            props.setProperty("python.path", path1 + ":" + path2);
        }
        PythonInterpreter.initialize(System.getProperties(), props,
                new String[] {""});

        PySystemState pySysState = new PySystemState();
        log.info("Jython sys state initialized. sys.path: " + pySysState.path);



Example project is here (you need java 7):
https://github.com/snasrallah/DiskSpaceInformer

Jython code is here:

https://github.com/snasrallah/DiskSpaceInformer/blob/master/src/dsi/Utils.py

To see it running via jnlp (note the jtable summary of disk space is in jython):
http://www.spirale.co.uk/dsi/DiskSpaceInformer.jnlp

Be interested to see if anyone has had these issues.

Regards
Simon







------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2


_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users