Re: Location of __run__.py
David Handy <David.Handy <at> sas.com>
2008-05-07 15:35:38 GMT
This advice, given below:
java org.python.util.jython -jar myjar.jar
is incorrect. If you just run java without any arguments, it will tell you
what went wrong:
C:\>java
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
...
In other words, you either set up the classpath to include the jar file, and then run java with the class name
containing your main Java method, OR you use the -jar option, BUT NOT BOTH IN THE SAME COMMAND LINE.
For example, you can run:
java -classpath myjar.jar org.python.util.jython
OR
java -jar myjar.jar
I hope this helps-
David H
-----Original Message-----
From: jython-users-bounces <at> lists.sourceforge.net
[mailto:jython-users-bounces <at> lists.sourceforge.net] On Behalf Of DOUTCH GARETH-GDO003
Sent: Wednesday, May 07, 2008 11:09 AM
To: jython-users <at> lists.sourceforge.net
Subject: Re: [Jython-users] Location of __run__.py
Hi Dave,
I'm getting the following error whenever I launch:
$ java org.python.util.jython -jar jython.jar
Using the jar created with the standalone jar with __run__.py at the root:
Exception in thread "main" java.lang.NoClassDefFoundError: org/python/util/jython
Caused by: java.lang.ClassNotFoundException: org.python.util.jython
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
I've no idea what I'm doing wrong.
Cheers,
Gareth
-----Original Message-----
From: jython-users-bounces <at> lists.sourceforge.net
[mailto:jython-users-bounces <at> lists.sourceforge.net] On Behalf Of Dave Kuhlman
Sent: 05 May 2008 19:40
To: jython-users <at> lists.sourceforge.net
Subject: Re: [Jython-users] Location of __run__.py
DOUTCH GARETH-GDO003 <Gareth.Doutch <at> motorola.com> writes:
>
>
> Hi
> all,
>
>
> When creating an
> application using the standalone jar method, I have seen instructions
> stating
to
> place the startup script __run__.py at the root of the jar.
>
> However, whenever I am call
>
> java -jar jython.jar
>
> it is starting up to
> the command interface in the normal way, not running my __run__.py script.
What
> am I missing?
Yes, you can put your __run__.py in you jar file (at the root). But there are a couple of additional considerations.
Here are a few points that might help:
1. When you start your jar, in order to kick off the __run__.py file, use the following at the command line:
$ java org.python.util.jython -jar myjar.jar
2. The "if __name__== '__main__':" idiom does not seem to work. You will have to use something in __run__.py
that starts your app unconditionally.
3. One easy way to build a jar to which you add your __run__.py and other application specific code is by using
the Jython installer. There is an option to create a standalone jar file. When running the installer in GUI
mode, that option is a couple of screens in. When running in silent mode you can use something like the following:
$ java -jar jython_installer-2.2.1.jar -s -d Tmp -t standalone
Run the following for help:
$ java -jar jython_installer-2.2.1.jar --help
4. There is a bit more about deployment and building jars etc here:
http://wiki.python.org/jython/LearningJython#deployment-and-distribution
By the way, I wrote that "Deployment and Distribution" section of the Wiki, with the help of others. So, if
you find any errors in it or things that need to be added, please let me know, or fix it yourself.
Hope this helps.
- Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event.
There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone