通过 KornShell 脚本在 AIX 上运行 JAR 文件
我在我的 AIX 机器上运行以下命令。
/usr/java6_64/jre/bin/java -jar myapp.jar
然后,一切看起来都很好。 JAR 文件连接到数据库并执行它需要执行的任何操作。
但我需要将此命令(以及其他一些命令)放入脚本中。
因此,我创建了一个名为“script.ksh”的 KornShell (ksh) 脚本文件来执行上述操作。
#!/bin/ksh
/usr/java6_64/jre/bin/java -jar myapp.jar
但它给了我以下异常:
EXCEPTION: TerminateProcessException: Cannot connect to the database.
java.sql.SQLException: No suitable driver
现在,与 JDBC 驱动程序所在的 JAR 文件和 script.ksh 文件位于同一位置,有一个“lib”文件夹。
shell 脚本中是否缺少某些内容?就像类路径一样?我尝试在脚本中设置类路径
CLASSPATH=/home/path/to/lib/*.jar
但它仍然给我错误。看来是找不到驱动了有什么帮助吗?
I run the following command on my AIX machine.
/usr/java6_64/jre/bin/java -jar myapp.jar
Then, things look fine. The JAR file connects to the database and does whatever it needs to do.
But I need to put this command (plus a few others) in a script.
So I created a KornShell (ksh) script file called "script.ksh" to do the above.
#!/bin/ksh
/usr/java6_64/jre/bin/java -jar myapp.jar
But it is giving me the following exception:
EXCEPTION: TerminateProcessException: Cannot connect to the database.
java.sql.SQLException: No suitable driver
Now, there is a "lib" folder in the same location as the JAR file and script.ksh file where the JDBC driver is located.
Is there something I am missing in the shell script? Like classpath? I tried setting the classpath in the script with
CLASSPATH=/home/path/to/lib/*.jar
But it still gave me the error. Looks like it can't find the driver. Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试导出 CLASSPATH 变量。
Try exporting the
CLASSPATH
variable.