指定独立jython的类路径 [英] specifying classpath for standalone jython
问题描述
我试图通过jython在无法安装任何东西的服务器上运行python脚本.
I am trying to run a python script via jython on a server that I won't be able to install anything.
我可以跑步
java -jar jython.jar
,效果很好.我无法使用mm.mysql-2.0.14驱动程序,因为它找不到jar.我将类路径设置为包括它,就像在具有标准(即非独立)jython安装的测试系统上所做的那样.它仍然说找不到罐子.
and that works fine. I am unable to use mm.mysql-2.0.14 driver because it can't find the jar. I set the classpath to include it, as I did on a test system with a standard (that is, non-standalone) jython install. It still says it can't find the jar.
我尝试过类似的事情:
export CLASSPATH=/tmp/mm.mysql-2.0.14-bin.jar:/tmp/zxJDBC.jar;
java -jar jython.jar
export CLASSPATH=/tmp/mm.mysql-2.0.14-bin.jar:/tmp/zxJDBC.jar;
java -jar jython.jar
和
java -cp /tmp/mm.mysql-2.0.14-bin.jar -jar jython.jar
没有骰子.
仍然出现错误:zxJDBC.DatabaseError:未找到驱动程序[org.gjt.mm.mysql.Driver]
still the error: zxJDBC.DatabaseError: driver [org.gjt.mm.mysql.Driver] not found
推荐答案
在我的Windows环境中,我能够运行:
In my Windows environment I was able to run:
java -cp c:\jars\ojdbc6.jar;c:\jython2.5.2\jython.jar org.python.util.jython schema_ora.py
其中schema_ora.py
是我要运行的脚本,该脚本使用Oracle JDBC驱动程序.
where schema_ora.py
is a script I want to run which uses Oracle JDBC driver.
我也在Linux上尝试过:
I also tried it on Linux with:
[mn@test-db mn]# export CLASSPATH=/usr/local/jars/ojdbc6.jar; /usr/local/jython2.5.2/bin/jython -J-Xmx4048m schema_ora.py jdbc:oracle:thin:@192.168.19.128:1521:testdb usr passwd
因此可以以这种方式运行脚本.
So it is possible to run script that way.
对于您的问题,也许您无权查看MySQL JDBC驱动程序? 我假设您使用的是Linux,因此您可以检查是否可以看到该文件:
As for your problem maybe you do not have rights to see MySQL JDBC driver? I assume you use Linux, so you can check if you can see that file:
file /tmp/mm.mysql-2.0.14-bin.jar
我在Linux机器上使用Oracle驱动程序进行了尝试:
I tried it with Oracle driver on my Linux box:
[mn@test-db mn]# file /usr/local/jars/ojdbc6.jar
/usr/local/jars/ojdbc6.jar: Zip archive data, at least v2.0 to extract
这篇关于指定独立jython的类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!