ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> Jython-users
Jython-users
RE: [Jython-users] call a java-method from embedded interpreter
by Jeff Emanuel other posts by this author
Oct 13 2003 3:30PM messages near this date
[Jython-users] Creating Objects from XML Schemas | AW: [Jython-users] call a java-method from embedded interpreter
In addition to what Diez said, you could change

> PyObject pyObject = interp.eval("obj1");
> pyObject.__getattr__("run").__call__(); <--- doesn't work?!

to

MyClass myObject = (MyClass)interp.get("obj1",MyClass.class);
myObject.run();




 

-----Original Message-----
From: Kay
To: jython-users@[...].net
Sent: 10/12/2003 5:58 PM
Subject: [Jython-users] call a java-method from embedded interpreter


Hello!

I want to start the method "run()" (with an embedded interpreter)
from 'MyClass.java', but i'm getting the following exception:

--> 
Traceback (innermost last):   (no code object) at line 0 TypeError:
run():
expected 1 args; got 0 <--

... dir() shows "obj1";
The InteractiveConsole starts 'run' without problems!
Do you know, where is the mistake?

Thx!

Regards,
Kay


-=>  App.java <=-
:

Object obj;
:
interp = new PythonInterpreter();
interp.set("obj1", obj);
PyObject pyObject = interp.eval("obj1");
pyObject.__getattr__("run").__call__(); <--- doesn't work?!

:



-=>  MyClass.java <=-

public class MyClass implements Runnable{

    public JFrame frame = new JFrame();


    public void run() {
      System.out.println("Starting...");
      frame.setSize(200,200);
      frame.show();
    }
}

********************************************************************




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Jython-users mailing list
Jython-users@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-users


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Jython-users mailing list
Jython-users@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-users
Thread:
Jeff Emanuel
Kay
Diez B. Roggisch

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved