user1870400
user1870400

Reputation: 6364

install java successfully using the dockerfile however its says java command not found

Here is my docker file

RUN apt-get install -y --no-install-recommends software-properties-common
RUN add-apt-repository -y ppa:openjdk-r/ppa
RUN apt-get update
RUN apt-get install -y openjdk-8-jdk
RUN apt-get install -y openjdk-8-jre
RUN update-alternatives --config java
RUN update-alternatives --config javac

when I log into the container using sudo docker run -t -i dockerfile and type java or javac it works. I can see it has been installed successfully however when i run it with the file below it says "java command not found"?

RUN apt-get install -y --no-install-recommends software-properties-common
RUN add-apt-repository -y ppa:openjdk-r/ppa
RUN apt-get update
RUN apt-get install -y openjdk-8-jdk
RUN apt-get install -y openjdk-8-jre
RUN update-alternatives --config java
RUN update-alternatives --config javac
ENTRYPOINT ["java" "-jar", "/home/project/hello.jar"]
CMD [""]

sudo docker run -t -i dockerfile java command not found ?

Upvotes: 8

Views: 32334

Answers (2)

kliew
kliew

Reputation: 3183

ENTRYPOINT ["java" "-jar", "/home/project/hello.jar"]

You forgot a comma before "-jar".

Upvotes: 15

MrE
MrE

Reputation: 20798

you're probably missing the JAVA_HOME and PATH declaration.

ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 #This can vary
ENV PATH $PATH:$JAVA_HOME/bin

And build the docker image with --no-cache option

Upvotes: 5

Related Questions