Jython 2.7.0 “Final Release” on Windows - difficulty including jars

♀尐吖头ヾ 提交于 2019-12-25 05:37:29

问题


I have a few projects which run using Jython 2.7b1 where I add the jars (in fact all the jars in a directory) by doing this:

set CLASSPATH=.;"%SYSADMIN%\resources\java jar files/*"
set JYTHONPATH=...
C:\jython2.7b1\jython myproj\__main__.py 

But my latest project is using 2.7.0FR and this "set CLASSPATH" approach doesn't seem to work. I then tried this:

D:\apps\jython2.7.0\bin\jython -Dpython.path="%SYSADMIN%\resources\java jar files/*" my_latest_proj\__main__.py

... but it didn't work. Then I wanted to see whether I could load an individual .jar:

D:\apps\jython2.7.0\bin\jython -Dpython.path="%SYSADMIN%\resources\java jar files\lucene-analyzers-common-4.6.0.jar" my_latest_proj\__main__.py 

This didn't work either: the following line

from org.apache.lucene.analysis.fr import FrenchAnalyzer

leads to the following error: "No module named apache"... nor is there any "unpacking" of the jar as you typically see with Jython the first time you use a jar.

Finally I tried this:

set CLASSPATH=.;"%SYSADMIN%\resources\java jar files\lucene-analyzers-common-4.6.0.jar"

... same thing: "No module named apache"

NB I have no trouble getting jars to work from within my project when running it under Eclipse.

Can anyone tell me what I'm doing wrong?


回答1:


Aha...!

1) It appears that with Jython2.7.0FR you have to use forward slashes in paths in the CLASSPATH, even in a Windows OS. This appears to be a change relative to 2.7b1...

2) I also seem to find that paths with spaces are to be avoided... previously I could enclose such a path in quotes and it would work OK. This seems not to work any more.

Any comments from the Jython "High Command" would be welcome...



来源:https://stackoverflow.com/questions/33434083/jython-2-7-0-final-release-on-windows-difficulty-including-jars

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!