开发者

I can't get PyDev - PYTHONPATH to recognize my Java src directory in Eclipse

开发者 https://www.devze.com 2023-04-04 18:06 出处:网络
In the Project Properties > PyDev - PYTHONPATH > Source Folders tab I have my Java source directory listed. However, when I try to run my Python file using right-click > Run As > Jython Run, I get \"I

In the Project Properties > PyDev - PYTHONPATH > Source Folders tab I have my Java source directory listed. However, when I try to run my Python file using right-click > Run As > Jython Run, I get "ImportError: cannot import name Person". This is a very simple Python script:

from com.entities import Person

person = Person()
print person.getFirstName()

I've read some people discuss creating a JAR of the Java application, and then referencing the JAR, but it seems pretty clear that I should be able to referenc开发者_开发技巧e my source directory.

EDIT

So I just tested using a JAR reference containing my class and that worked. So why won't a source folder reference work?


Actually, it depends on how you structure your java code... you have to add as a source folder the folder that has your .class files (as that's the folder that's added to your pythonpath -- so, depending on how you structure your project, that may be your 'bin' folder).

Reference: read the last lines in: http://pydev.org/manual_101_project_conf2.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号