首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Jython Jar依赖项导入失败

Jython Jar依赖项导入失败
EN

Stack Overflow用户
提问于 2012-08-01 14:37:38
回答 1查看 467关注 0票数 0

我在jar中有一个应用程序,它依赖于不同jar中的少数几个库。

这就是我的问题:当我只导入我的主应用程序文件时,jython似乎正确地加载了类,但却通过NoClassDefError (在支持的库jars中表示的jars)抱怨缺少类。

但是,如果我现在将jar添加到类路径中,Jython将无法再找到原始导入,并会报错:ImportError: No module named edu

我的代码:

代码语言:javascript
运行
复制
import sys 

def setClassPath():
     libDir = "/Users/gestalt/Documents/msmexplorer_git/msmexplorer/MSMExplorer/"
     classPaths = [ 
          "dist/MSMExplorer.jar"
          "dist/lib/prefuse.jar" #the missing class is here, but this line causes package edu to go missing
     ]   
     for classPath in classPaths:
          sys.path.append(libDir+classPath)

def runJavaClass():
     from edu.stanford.folding.msmexplorer import MSMExplorer
     me = MSMExplorer()

def main():
     setClassPath()
     runJavaClass()

if __name__ == "__main__":
     main()

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2012-08-01 15:03:19

这听起来可能很愚蠢,但这是某种特殊的语法错误。jar规范之间必须使用逗号:

代码语言:javascript
运行
复制
"dist/MSMExplorer.jar",
"dist/lib/prefuse.jar" 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11753803

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档