来自 shell 脚本的错误 运行 jar 命令

Error Running jar command from shell Script

我需要将 Jar 的内容提取到特定位置。当我 运行 下面的命令提取 jar 时,它工作正常。

jar -xf location/ex.jar

我在脚本 (.sh/.ksh) 中放置的相同命令。当我 运行 脚本时,出现以下错误:

 jar:  not found.

两个用户都是我运行和script/command的用户。我正在使用 AIX 服务器。 感谢您的帮助。

您的 PATH 变量设置不正确。

  1. 找到您的 java 安装:find / -name "java"
  2. 将正确的路径添加到您的 PATH 变量:export PATH="$PATH:/location/to/java/jre/bin"

或者,直接使用 unzip /location/ex.jar