473,473 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Calling Jython code from Java

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
Jul 18 '05 #1
1 2206
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.

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tennessee James Leeuwenburg | last post by:
Hi all, Sorry for the newb question, but Googling and FAQing didn't work. Is it correct that Jython can only access Java classes which are inside JAR archives in the JYTHON_HOME directory? IT...
4
by: Michael Chermside | last post by:
Ype writes: > For the namespaces in Jython this 'Python internal thread safety' > is handled by the Java class: > > http://www.jython.org/docs/javadoc/org/python/core/PyStringMap.html > > which...
4
by: angel | last post by:
A java runtime environment includes jvm and java class (for example classes.zip in sun jre). Of course jython need jvm,but does it need java class. Thanx
7
by: Jan Gregor | last post by:
Hello I found that jython catches exact java exceptions, not their subclasses. Is there some way to get around this limitation (or error) ? My program has class representing database source...
3
by: Jim Hargrave | last post by:
I've read that it is possible to compile jython to native code using GCJ. PyLucene uses this approach, they then use SWIG to create a Python wrapper around the natively compiled (java) Lucene. Has...
6
by: Mike Wimpe | last post by:
Other than being used to wrap Java classes, what other real use is there for Jython being that Python has many other GUI toolkits available? Also, these toolkits like Tkinter are so much better for...
12
by: Mark Fink | last post by:
I wrote a Jython class that inherits from a Java class and (thats the plan) overrides one method. Everything should stay the same. If I run this nothing happens whereas if I run the Java class it...
3
by: donkeyboy | last post by:
All, I'm having issues installing Jython on Windows XP. I've looked on the web and this newsgroup but to no avail. Any suggestions? The shell listing is below: NB I've got Cygwin installed,...
2
by: donkeyboy | last post by:
All, I've tried the jythonc compiler to try and create an applet to see how it works, but I get a number of Java compile errors that are way above my knowledge. Does anyone know what any of the...
5
by: sarup26 | last post by:
Hello .. I would like to know more about Python and Jython? What is the difference between both of them? What is the future for Jython and which are the areas where it is used? Swot
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.