• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling python function from java

 
Raj Sikka
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I have a java file as below :
public class myClass
{
public int myMethod() {
PythonInterpreter interpreter = new PythonInterpreter();
//Code to write
}
}
I have one python file as below :
import string;
from jythonlib.tl1pc.utils import *
class myPythonClass:

def abc(self):
print "calling abc"
tmpb = {}
tmpb = {
'status' : 'SUCCESS'
}
return tmpb
Now the problem is i want to call "abc" function of my python file from "myMethod" method of my java file.
How to make these kind of calls ? Pls explain me with piece of code.
Thanks in advance,
Raj

Raj - please do not use URGENT in your topic title (So called URGENT topics are likely to be ignored or made fun of)
[ January 14, 2004: Message edited by: Barry Gaunt ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before you started playing around with embedding the Jython interpreter, did you consider this method from the Jython FAQ?

If you really need embedding, then there's a trivial example here.
The book Jython for Java Programmers has a whole chapter dedicated to embedding the Jython/Python interpeter into Java programs. Maybe you can download the examples from the book.
Jython Essentials also covers using the Jython interpreter from Java.
[ January 14, 2004: Message edited by: Barry Gaunt ]
 
Raj Sikka
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Barry.
Where can I download examples from the book "Jython for Java Programmers"?
Are they available free on net ?
If yes can you please tell me the link.
Thanks,
Raj
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess it's the book's companion website. But's not reachable at the moment
 
Raj Sikka
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Berry,
I will try to download.
Raj
 
eswari Malluru
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raj Sikka,

I am also trying for similar example. Please give an example if you downloaded and implemented this. I failed in downloading this book.

Thanks,
Eshwari
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic