I have issue with updated symlink on java after maven installation. I use simple docker file:
FROM java:8
RUN ["java", "-version"]
RUN apt-get update && apt-get install -y maven && rm -rf /var/lib/apt/lists/*
RUN ["java", "-version"]
CMD ["java", "-version"]
During build I've got next log:
Step 0 : FROM java:8
---> 4cd29d33e3f4
Step 1 : RUN java -version
---> Running in 1c528620f318
openjdk version "1.8.0_66-internal"
OpenJDK Runtime Environment (build 1.8.0_66-internal-b01)
OpenJDK 64-Bit Server VM (build 25.66-b01, mixed mode)
---> d25e96460a85
Removing intermediate container 1c528620f318
Step 2 : RUN apt-get update && apt-get install -y maven && rm -rf /var/lib/apt/lists/*
....installation logs....
Setting up openjdk-7-jre-headless:amd64 (7u79-2.5.6-1~deb8u1) ...
update-alternatives: using /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/rmid to provide /usr/bin/rmid (rmid) in auto mode
update-alternatives: using /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in auto mode
So as you can see maven brings java 7 and update-alternatives makes it default version. So I have several questions:
I think all this is distro specific.
As in: In your chosen distro (Ubuntu?) the particular maven package that you are installing has a dependency to OpenJDK 7 (and not 8).
I see two options for a Java 8 / maven setup:
I tried out your setup see
https://github.com/BITPlan/docker-stackoverflowanswers/tree/master/33324470
and by running:
./build
./run
i entered a bash to see what the situation is:
Java Version
root@940c282bd6ad:/# java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-1~deb8u1)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
So by default this distro uses an OpenJDK 1.7
Maven Version
root@940c282bd6ad:/# mvn -version
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.8.0_66-internal, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.1.10-boot2docker", arch: "amd64", family: "unix"
The maven uses Oracle Java 1.8
Now you have got multiple options
Select another default java as outlined in
https://askubuntu.com/questions/272187/setting-jdk-7-as-default
root@940c282bd6ad:/# update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode
1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1069 manual mode
Switch the default java version as outlined in:
https://askubuntu.com/questions/491778/switch-to-oracle-java-jdk-in-14-04
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.