Change JAVA_HOME in docker

Shoreki :

The legacy web application which I want to dockerise uses some old classes like com/sun/image/codec/jpeg/ImageFormatException which were supported till Java SE7. Now in the docker container default jdk getting (on installing tomcat-6 container) is

java version "1.7.0_131"
OpenJDK Runtime Environment (IcedTea 2.6.9) (7u131-2.6.9-2~deb8u1)

OpenJdk doesn't support these classes

I used update-alternatives to install Oracle Jdk7.80

After loading container, on giving java -version I am getting

java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

However, echo $JAVA_HOME after entering the container gives /docker-java-home/jre which again points to OpenJdk. How can I set JAVA_HOME to the Oracle Jdk home that I installed?

dpr :

You can simply set/change environment variables of your docker image by using the ENV command in your Dockerfile:

ENV JAVA_HOME /path/to/java

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=441218&siteId=1