Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Calling Jython code from Java

Reply
Thread Tools

Calling Jython code from Java

 
 
Raja
Guest
Posts: n/a
 
      05-18-2004
I have a java class thats trying to call something in python. This
works fine when i do a jythonc on the python script.
When i call another python script from the __init__ of my called
python script, things go bad.i get this message
AttributeError: class 'configuration' has no attribute
'configuration'
when calling the constructor.
This is my python script thats called by the java class
testconfig.py
=============
import configuration
import java.lang

class testconfig(java.lang.Object):

def __init__(self):
"""@sig public testconfig()"""
self._cfg = configuration.configuration("/sources/jmxproto")

def getValue(self, whatVar):
pass

and the other script is configuration.py
class configuration:

def __init__(self, runtimeDir=None):
"""@sig public configuration(java.lang.String dir)"""
""" Some code in here """

When i call testconfig.py, i get the error mentioned above. Any clues?

Thanks
Raja
 
Reply With Quote
 
 
 
 
Derek Thomson
Guest
Posts: n/a
 
      05-18-2004
Raja wrote:
> I have a java class thats trying to call something in python. This
> works fine when i do a jythonc on the python script.


[snip]

>
> class testconfig(java.lang.Object):
>
> def __init__(self):
> """@sig public testconfig()"""
> self._cfg = configuration.configuration("/sources/jmxproto")


[snip]

> class configuration:
>
> def __init__(self, runtimeDir=None):
> """@sig public configuration(java.lang.String dir)"""
> """ Some code in here """
>
> When i call testconfig.py, i get the error mentioned above. Any clues?


In Python, you just use the class name to create instances.

So I think that perhaps:

self._cfg = configuration.configuration("/sources/jmxproto")

Should be:

self._cfg = configuration("/sources/jmxproto")

IIRC the "@sig" declaration only comes into play when attempting to use
the class from *Java* code. That's why there is no "configuration"
attribute.

Regards,
Derek.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling batch files in jython potchi Software 0 05-20-2011 09:12 AM
Jython code to parse command line arguments potchi Python 0 05-18-2011 05:58 AM
FW: [Jython-users] Jython Licensing Question Pinegar, Kent T Python 0 07-24-2008 01:38 PM
FW: [Jython-users] ERROR : parsing xml in jython Divya Prakash Python 0 12-19-2006 02:49 PM
[Jython-users] ANN: SPIRO - a cPython->Jython bridge (amongst otheruses) David McNab Python 0 04-09-2004 10:20 AM



Advertisments