我有 Gentoo Docker 映像。我正在嘗試在容器內安裝 Java 8。網路上有教程,但沒有幫助。
我嘗試運行:
emerge --verbose dev-java/icedtea-bin:8
但得到這個輸出:
The following USE changes are necessary to proceed:
(see "package.use" in the portage(5) man page for more details)
# required by net-print/cups-filters-1.21.6::gentoo[postscript]
# required by net-print/cups-2.2.7::gentoo
# required by dev-java/icedtea-bin-3.10.0-r1::gentoo[cups,-multilib]
# required by virtual/jdk-1.8.0-r3::gentoo
# required by virtual/jre-1.8.0-r1::gentoo
# required by dev-java/icedtea-web-1.6.2::gentoo
>=app-text/ghostscript-gpl-9.26 cups
Use --autounmask-write to write changes to config files (honoring
CONFIG_PROTECT). Carefully examine the list of proposed changes,
paying special attention to mask or keyword changes that may expose
experimental or unstable packages.
答案1
可以透過下載 tar.gz 檔案來安裝它,如下所示:
...
RUN wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz \
&& mkdir /opt/jdk \
&& tar zxf jdk-8u131-linux-x64.tar.gz -C /opt/jdk \
&& update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_131/bin/java 100 \
&& update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_131/bin/javac 100 \
&& update-alternatives --display java \
&& update-alternatives --display javac \
&& rm -rf jdk-8u131-linux-x64.tar.gz
...
答案2
運行 wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie"http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz 運行 mkdir /opt/jdk 運行 tar zxf jdk-8u131-linux-x64.tar.gz -C /opt/jdk ENV PATH=$PATH:/opt/jdk/jdk1.8.0_131/bin