From: Mollenkopf, A. <Ada...@fe...> - 2009-02-19 00:40:21
|
I am having trouble getting Jython to execute a very simple custom java class. My classpath appears to be set appropriately because I can verify that it works by executing the main method of the object from a command prompt. However when I run it with jython.bat it fails to import the object. Here is the error message and other associated material: C:\jython2.2.1\fedex>jython.bat adam.py Traceback (innermost last): File "adam.py", line 1, in ? File "C:\jython2.2.1\fedex\adam.py", line 3, in ? NameError: Adam C:\jython2.2.1\fedex\adam.py contains: from adam import *; Adam.doSomething(); C:\jython2.2.1\fedex\adam\Adam.java contains: package adam; public class Adam { public static void doSomething() { System.out.println("doing something."); } public static void main(String _args[]) { System.out.println("Adam Main"); } } Directory of C:\jython2.2.1\fedex\adam: 02/18/2009 04:25 PM 503 Adam.class 02/18/2009 04:25 PM 221 Adam.java CLASSPATH=C:\jython2.2.1\jython.jar;C:\jython2.2.1\fedex I am running Python 3.0.1. Any ideas? Thanks in advance for any assistance you can provide, Adam |
From: Alan K. <jyt...@xh...> - 2009-02-19 15:05:33
|
[Adam] > I am having trouble getting Jython to execute a very simple custom java class. [.. snip ..] > I am running Python 3.0.1. Are you running jython or are you running python 3.0.1? The two are fundamentally different. The only version of python that is at version 3.0.1 is cpython, which is implemented in C, and cannot be used to run java libraries (well, not easily anyway). Jython is a different implementation of the python language that runs on the Java Virtual Machine, and is just reaching version 2.5; version 3.0 of jython is some way in the future. If you can clarify which version you are using, it may be possible to resolve your problem. Alan. |
From: Tobias I. <th...@gm...> - 2009-02-19 17:24:15
|
If you _are_ running Jython it looks like your problem is a name conflict, both your python module and java package have the same name. Jython will import the python module first in this case (the very same module that you are running), and this module does not define anything with the same name as the java class you are trying to access. On Thu, Feb 19, 2009 at 4:05 PM, Alan Kennedy <jyt...@xh...> wrote: > [Adam] > > I am having trouble getting Jython to execute a very simple custom java > class. > [.. snip ..] > > I am running Python 3.0.1. > > Are you running jython or are you running python 3.0.1? The two are > fundamentally different. > > The only version of python that is at version 3.0.1 is cpython, which > is implemented in C, and cannot be used to run java libraries (well, > not easily anyway). > > Jython is a different implementation of the python language that runs > on the Java Virtual Machine, and is just reaching version 2.5; version > 3.0 of jython is some way in the future. > > If you can clarify which version you are using, it may be possible to > resolve your problem. > > Alan. > > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, > CA > -OSBC tackles the biggest issue in open source: Open Sourcing the > Enterprise > -Strategies to boost innovation and cut costs with open source > participation > -Receive a $600 discount off the registration fee with the source code: > SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |
From: Mollenkopf, A. <Ada...@fe...> - 2009-02-19 17:40:53
|
Tobias - Thank you very much - changing the package name to adampkg allowed me to successfully use 'from adampkg import Adam;'. Alan - Thank you as well for clarifying that Jython has it's own JVM based implementation of Python 2.5. I assumed it was using my installed 3.0.1 Python version but now understand that it is not using that at all. This helped me to make sense of some syntactical changes I was having to make when converting existing standard .py files to Jython. Thanks again for you quick assistance on this, Adam M. ________________________________ From: Tobias Ivarsson [mailto:th...@gm...] Sent: Thursday, February 19, 2009 12:24 PM To: Alan Kennedy; Mollenkopf, Adam Cc: jyt...@li... Subject: Re: [Jython-users] Trouble Invoking Simple Custom Java object from Python in Py 3.0.1 If you _are_ running Jython it looks like your problem is a name conflict, both your python module and java package have the same name. Jython will import the python module first in this case (the very same module that you are running), and this module does not define anything with the same name as the java class you are trying to access. On Thu, Feb 19, 2009 at 4:05 PM, Alan Kennedy <jyt...@xh...> wrote: [Adam] > I am having trouble getting Jython to execute a very simple custom java class. [.. snip ..] > I am running Python 3.0.1. Are you running jython or are you running python 3.0.1? The two are fundamentally different. The only version of python that is at version 3.0.1 is cpython, which is implemented in C, and cannot be used to run java libraries (well, not easily anyway). Jython is a different implementation of the python language that runs on the Java Virtual Machine, and is just reaching version 2.5; version 3.0 of jython is some way in the future. If you can clarify which version you are using, it may be possible to resolve your problem. Alan. ------------------------------------------------------------------------ ------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Jython-users mailing list Jyt...@li... https://lists.sourceforge.net/lists/listinfo/jython-users |