Jython 的类路径问题
我有一个关于运行与 jython 相关的两个命令的差异的问题。我遇到了类路径和数据库驱动程序的问题。
对我有用的是执行以下操作: jython -J-classpath ../lib/mysql-connector-java-5.1.7.jar test.py /home/test/data
运行该命令一切都按预期运行,所以我想组合我的脚本作为 jar 运行所以不需要jython。一旦我完成了 jar 的创建,一切都会运行,直到我需要驱动程序并返回驱动程序未找到错误。
我按如下方式运行: java -cp ../lib/mysql-connector-java-5.1.7.jar mytest.jar test.py /home/test/data
我不确定我明白为什么一个可以工作而另一个不能工作?
谢谢
I had a question on the diffrence of running two commands related to jython. I'm having issues with classpath and db drivers.
What works for me is doing the following:
jython -J-classpath ../lib/mysql-connector-java-5.1.7.jar test.py /home/test/data
Running that command everything runs as expected so I wanted to combine my scripts to be run as a jar so not to require jython. Once I finshed creating my jar everything runs until it comes to the point where I need the driver and returns a driver not found error.
I run this as the following:
java -cp ../lib/mysql-connector-java-5.1.7.jar mytest.jar test.py /home/test/data
I'm not sure I understand why one would work and the other would not work?.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我让它工作了,但我不确定为什么它会工作。我希望有人能给我解释一下。我重建了 mytest.jar jar 并在构建 jar 时将所需的类路径包含在 mainifest 中,这似乎允许我在 java 中使用:
java -cp mytest.jar test.py /home/test/data
为什么将类路径包含在 mainfest 中而不是在命令行中会产生不同的结果?
I got it working but I'm not sure why it works. I hope someone can explain to me. I rebuilt my mytest.jar jar and included the needed classpaths in the mainifest when building the jar and this seems to allow me to use in java as:
java -cp mytest.jar test.py /home/test/data
Why would including the classpath in the mainfest instead of at the command line produce diffrent results?