开发者

Add python module to JAR classpath in Eclipse

开发者 https://www.devze.com 2023-03-19 15:50 出处:网络
I have a Java project that utilizes Jython to interface with a Python module. With my configuration, the program runs fine, however, when I export the project to a JAR file, I get the following error:

I have a Java project that utilizes Jython to interface with a Python module. With my configuration, the program runs fine, however, when I export the project to a JAR file, I get the following error:

Jar export finished with problems. See details for additional information.
  Fat Jar Export: Could not find class-path entry for 'C:Projects/this_project/src/com/company/python/'

When browsing through the generated JAR file with an archive manager, the python module is in fact inside of the JAR, but when I check the manifest, only "." is in the classpath. I can overlook this issue by manually dropping the module into the JAR file after creation, b开发者_开发技巧ut since the main point of this project is automation, I'd rather be able to configure Eclipse to generate properly configured JAR automatically. Any ideas?

*NOTE*I obviously cannot run the program successfully when I do this, but removing the Python source folder from the classpath in "Run Configurations..." makes the error go away.


Figured it out, had to add the source folder with the Python module in it as a class folder in the Build Path project properties. Not sure if this next part is necessary or not, but since the module is not compiled, I added the folder again as "Attached Source" after adding the class folder.


Have a look at the maven-jython-compile-plugin and its demo project at http://mavenjython.sourceforge.net/ . It allows bundling jython with dependencies into a standalone jar.

0

精彩评论

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