我做了一个java程序。我用的是eclipse,它是一个maven项目。现在,当我从 Windows 命令提示符运行该程序时,它运行良好。这里我如何从 Windows 命令提示符运行它
D:\Personal Work\eclipse 32 Bit\workspace\....\target\classes>
java -cp ".;..\dependency-jars\*" com/softech/ls360/integration/BatchImport vintners
工作正常。我的依赖 jar 文件夹包含这些 jar 文件
现在当我从 Linux 运行相同的程序时。这是我的运行方式
root@Basit:/home/test/script/classes# java -cp .;../dependency-jars/*; com.s
oftech.ls360.integration.BatchImport vintners
然后我收到错误
....
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
../dependency-jars/commons-collections-3.2.1.jar: line 1: PK??: command not found
../dependency-jars/commons-collections-3.2.1.jar: line 2:
../dependency-jars/commons-collections-3.2.1.jar: line 2: ?8: command not found
../dependency-jars/commons-collections-3.2.1.jar: line 3: syntax error near unex
pected token `)'
../dependency-jars/commons-collections-3.2.1.jar: line 3: ? ¶META-INF/MANIFE
ST.MF?VKo
_¦?z? ?%+v?N??!ö!P@
(
_?o.5?$
com.softech.ls360.integration.BatchImport: command not found
为什么我会收到这些错误。我怎样才能在Linux上运行它?请帮忙
谢谢
最佳答案
在 Linux 环境下,您需要在类路径中使用 :
而不是 ;
。假设您已正确放置 jar ,则只需更改此即可:
java -cp .;../dependency-jars/*; com.s
oftech.ls360.integration.BatchImport vintners
至
java -cp .:../dependency-jars/*: com.s
oftech.ls360.integration.BatchImport vintners
应该可以
在此处了解有关设置类路径的更多信息:http://docs.oracle.com/javase/tutorial/essential/environment/paths.html
关于java - 在 Linux 上运行程序时出现错误。在 Windows 上它工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18252735/