Jython 的类路径问题

发布于 2024-10-03 08:58:25 字数 404 浏览 0 评论 0原文

我有一个关于运行与 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖乖公主 2024-10-10 08:58:25

我让它工作了,但我不确定为什么它会工作。我希望有人能给我解释一下。我重建了 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文