繁体   English   中英

环境路径-终端OSX

[英]Environment Path - Terminal OSX

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

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

输入“哪个java”

应该输出类似以下内容:

/usr/bin/java

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM