环境路径 - 终端OSX

时间:2012-05-18 20:59:33

标签: macos environment-variables

我可以在终端中直接运行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`

研究告诉我,这可能是环境路径问题?使用terminal vs cron时如何判断我的路径是什么?

我正在从cron中调用java,crontab就像:

0 3 * * * * java -classpath /Users/tb582/Desktop/sample1.jar:/Users/tb582 ......

1 个答案:

答案 0 :(得分:0)

只需在cron中指定整个路径:

输入“which java”

应输出与此类似的内容:

/usr/bin/java