我可以直接在终端中运行 java -classpath 命令而不会出现问题,但是一旦我尝试在 cron 中执行它就会引发此错误:
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available (implies -server, only for x86_64)
-client to select the "client" VM
-server to select the "server" VM
-jvm is a synonym for the "client" VM [deprecated]
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output`
研究告诉我,这可能是环境路径问题?使用终端与 cron 时如何判断我的路径是什么?
我正在从 cron 调用 java,crontab 类似于:
0 3 * * * * java -classpath /Users/tb582/Desktop/sample1.jar:/Users/tb582……