how to import Java class with Python using Eclipse?
Posted
by JChao
on Stack Overflow
See other posts from Stack Overflow
or by JChao
Published on 2010-05-20T22:58:17Z
Indexed on
2010/05/20
23:00 UTC
Read the original article
Hit count: 230
Hi, I'm trying to write Jython where the Python file imports classes from Java I'm using Eclipse with PyDev.
My Python code looks like:
from eclipsejavatest import eclipseJavaTest
from eclipsejavatest import JavaClass
class eclipsePyPrint(eclipseJavaTest):
def eclipsepyMain(self):
print "python main method"
eclipseJavaTest.printerCount(4)
print eclipseJavaTest.gotoPython()
eclipseJavaTest.printerSentence()
samplepyClass = JavaClass("Jython plain")
samplepyClass.setName("jython fancy")
print samplepyClass.getName()
but I'm getting the error ImportError: No module named eclipsejavatest
The Python project references the Java project. I've tried exporting the Java project and adding the .jar to the Jython Class Path for the Python project.
I'm not sure what to do to get this to work.
© Stack Overflow or respective owner