在 Ubuntu 12.04 上非交互地安装 Java 1.7

在 Ubuntu 12.04 上非交互地安装 Java 1.7

我需要Java 1.7在多台机器上安装,因此我想使用脚本来完成。问题是安装要求输入某些选项(具体来说是“Y”,然后是“OK”,最后是“Yes”)。我遇到了这个问题:

在 Ubuntu 上自动安装 postfix

我非常确定这个过程是相同的。但我不知道原帖者是如何知道变量名的(?)比如postfix postfix/mailname等等。

如果有人能提供更直接的答案,我们将不胜感激。

编辑1:

我尝试设置sudo dpkg-reconfigure debconfnon-interactive并选择警报级别为critial。然后我尝试执行sudo apt-get install oracle-java7-installer并收到此错误:

Need to get 0 B/18.6 kB of archives.
After this operation, 193 kB of additional disk space will be used.
Preconfiguring packages ...
(Reading database ... 47992 files and directories currently installed.)
Unpacking oracle-java7-installer (from .../oracle-java7-installer_7u51-0~webupd8~4_all.deb) ...

oracle-license-v1-1 license could not be presented
try 'dpkg-reconfigure debconf' to select a frontend other than noninteractive

dpkg: error processing /var/cache/apt/archives/oracle-java7-installer_7u51-0~webupd8~4_all.deb (--unpack):
 subprocess new pre-installation script returned error exit status 2
Errors were encountered while processing:
 /var/cache/apt/archives/oracle-java7-installer_7u51-0~webupd8~4_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

想必与 Java 8 相同

echo debconf shared/accepted-oracle-license-v1-1 select true | \
  sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | \
  sudo debconf-set-selections

apt-get -y install oracle-java7-installer oracle-java7-set-default

答案2

apt-get install -y --force-yes oracle-java7-installer 应该可以解决问题

相关内容