Nevermind, it is all down there at the very end of the tutorial -- I didn't realize there was more. I think my next step will be to try to build a version of the Jython standalone Jar to target earlier Java versions ( mostly because macs  can't always update to the latest Java version without purchasing the next OS revision )


On Fri, Dec 6, 2013 at 9:46 PM, M.Rule <mrule7404@gmail.com> wrote:
Please disregard that error relating to "proxies", it is not reproducible.

I was looking at http://launch4j.sourceforge.net/
this looks like a useful tool for packaging Jar files.

The only problem is that I don't think it works with the JARs built following the tutorial at  https://wiki.python.org/jython/JythonFaq/DistributingJythonScripts

The command needed to run those JARs is something like

java -cp ./myapp.jar org.python.util.jython -jar myapp.jar

To get a true click-to-launch JAR in Windows, and to use programs like launch4j which can bundle executables, I suspect that we need to make a JAR that can be invoked like this

java -jar myapp.jar

So far, I haven't figured out how to do this. If the Python source is _outside_ the JAR file, we can pass it as a command line argument, but if the Python source is _inside_ using the "__run__.py" approach, I'm at a loss. It doesn't seem like the tutorial covers this case.

Any leads?

Best,
Michael.


On Fri, Dec 6, 2013 at 7:57 PM, M.Rule <mrule7404@gmail.com> wrote:
Interesting, when I try to run the packaged Jar in windows, I get the following error:

java.lang.NoClassDefFoundError: IllegalName: org.python.proxies../myapp.jar$WatermarkView$8
        at java.lang.ClassLoader.preDefineClass(Unknown Source)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at org.python.core.BytecodeLoader$Loader.loadClassFromBytes(BytecodeLoader.java:119)
        at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:37)
        at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:52)
        at org.python.core.MakeProxies.makeClass(MakeProxies.java:30)
        at org.python.core.MakeProxies.makeProxy(MakeProxies.java:92)
        at org.python.core.PyType.setupProxy(PyType.java:646)
        at org.python.core.PyType.newType(PyType.java:210)
        at org.python.core.PyType.type___new__(PyType.java:152)
        at org.python.core.PyType$exposed___new__.new_impl(Unknown Source)
        at org.python.core.PyType.invokeNew(PyType.java:480)
        at org.python.core.PyType.type___call__(PyType.java:1638)
        at org.python.core.PyType.__call__(PyType.java:1628)
        at org.python.core.PyObject.__call__(PyObject.java:438)
        at org.python.core.Py.makeClass(Py.java:1680)
        at org.python.core.Py.makeClass(Py.java:1641)
        at org.python.core.Py.makeClass(Py.java:1633)
        at org.python.pycode._pyx0.f$0(__run__:344)
        at org.python.pycode._pyx0.call_function(__run__)
        at org.python.core.PyTableCode.call(PyTableCode.java:165)
        at org.python.core.PyCode.call(PyCode.java:18)
        at org.python.core.Py.runCode(Py.java:1302)
        at org.python.util.jython.runJar(jython.java:128)
        at org.python.util.jython.run(jython.java:279)
        at org.python.util.jython.main(jython.java:137)



On Fri, Dec 6, 2013 at 7:48 PM, M.Rule <mrule7404@gmail.com> wrote:
Another think which I am trying to understand: once packaged, we invoke the JAR as

java -cp ./myapp.jar org.python.util.jython -jar myapp.jar

My impression was that the "org.python.util.jython" in this line was for specifying the main class, but

If I specify the main class in the manifest like so
Main-Class: org.python.util.jython

and then run 
java -jar ./myapp.jar

I just get the Jython interpreter, instead of the app as defined in __run__,py loading.




On Fri, Dec 6, 2013 at 7:28 PM, mrule <MRule7404@gmail.com> wrote:
Although I got the classpath version working nicely, I decided to move ahead to try to package everything in a single Jar file. I ran into some things that confused me:

-- it seemed like Jython would only find auxillary Java classes if they were in their own package, and that package was part of com or org

-- there doesn't seem to be an easy way to pack resources for Jython in the Jar. The usual Java solution is something like class.getResource, but I couldn't figure out how to use that From jython. What I ended up doing is ... not great, which is create a Resource package in Java with a class called Resources that contains a single static method which wraps the class.getResource functionality. 

I'm sure I just haven't read the right documentation to know how to do this correctly, but I thought I should make a note of this.






On Fri, Dec 6, 2013 at 11:17 AM, Jeff Emanuel [via Python] <[hidden email]> wrote:
Re-zip it using "jar".  You need to make sure to tell jar about the manifest file.



On 12/6/2013 8:46 AM, M.Rule wrote:
Hi all,

I'd like to package a Jython program as a self-contained Windows executable. This is a small project for a user-base that cannot be expected to install/configure Java or Jython, it needs to be really simple. So I guess that means that Jython and Java will be bundled with the application ( much like ImageJ ).

I've been pretty confused about how to "deploy" jython. Yesterday, I tried following this https://wiki.python.org/jython/JythonFaq/DistributingJythonScripts. I got to the point where the tutorial seemed to be asking that I unzip the stand-alone Jython jar, add my project files, re-zip it, and things should work. The only thing is, as soon as I unzip-rezip the stand-alone Jython jar, it breaks ( even if I do not modify its contents ), and Java no longer recognizes it as a valid Jar file.

So, that tutorial doesn't work for me.  It also doesn't get me all the way to a self-contained Windows executable. Does anyone have any leads?

Best, Michael.


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk


_______________________________________________
Jython-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jython-users


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Jython-users mailing list
To start a new topic under jython-users, email [hidden email]
To unsubscribe from jython-users, click here.
NAML


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users