I am using windows os, So there is no issue with Font(java.awt) class object creation. but my testing environment is on linux. So on that I am getting NULL POINTER exception.
Cannot load from short array because "sun.awt.FontConfiguration.head" is null
After seacrhing I found that there should be fonts folder in usr/share directory on linux.
So someone can please suggest. Do I have to just copy fonts to that directory or there is other way to intsall?
For my configuration (java.18/Spring Boot/jib/Docker/ubuntu) I've used this these commands for resolving the issue:
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN apt-get update -y
RUN apt-get install -y apt-utils --no-install-recommends
RUN apt-get install -y libfreetype6 --no-install-recommends
RUN apt-get install -y fontconfig --no-install-recommends
RUN apt-get install -y fonts-dejavu --no-install-recommends
I have a python script that need java runtime. I am trying to build a docker image that contains contains both python 3.8 and Java 8. Here is my Dockerfile
FROM python:3.8-slim-buster
RUN apt-get update && apt-get install -y openjdk-8-jre
WORKDIR /
ADD ./requirements.txt /
ADD ./main.py /
RUN pip install -r requirements.txt
CMD [ "python", "./main.py" ]
However I get the following error when building the image
docker.errors.BuildError: The command '/bin/sh -c apt-get update && apt-get install -y openjdk-8-jre' returned a non-zero code: 100
I have tried different python base images but I get the same error. What am I doing wrong?
The package openjdk-8-jre is not available in Debian Buster repositories. The command :
RUN apt-get update && apt-get install -y openjdk-8-jre
returns :
[...]
E: Unable to locate package openjdk-8-jre
The command '/bin/sh -c apt-get update && apt-get install -y openjdk-8-jre' returned a non-zero code: 100
You have 2 options :
install a newer version of JRE (openjdk-11-jre) if you can
install OpenJDK 8 by downloading it manually : follow this guide https://linuxize.com/post/install-java-on-debian-10/
What I would like is to add Java (installation and JAVA_HOME) in an image.
I'm using this postgres dockerfile: https://github.com/docker-library/postgres/tree/master/9.6
Which I updated with the following :
RUN apt-get -y update
RUN apt-get -y install wget
RUN apt-get -y install sudo
RUN /bin/mkdir /usr/lib/jvm
RUN wget https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -O /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz
RUN sudo tar xfvz /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz --directory /usr/lib/jvm
RUN rm -f /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz
ENV JAVA_HOME /etc/alternatives/jre
Please note that I'm beginner so if something is obvious for you it may not be for me.
The issue is that, /usr/lib/jvm is not created thus java is not installed and also JAVA_HOME is empty when I run the image.
When I execute manually the instructions, it works, but I would like to make my dockerfile working.
As in title, I can not install openjdk-7-jdk using dockerfile from Ubuntu 14.04.
At that command RUN apt-get install -y openjdk-7-jdk I get the following error
Unable to fetch some archives, maybe run apt-get update or try with
--fix-missing?
failed to build: The command '/bin/sh -c apt-get install -y
openjdk-7-jdk' returned a non-zero code: 100
Before I already use RUN apt-get update -y && apt-get upgrade -y and additionally I was trying RUN sudo apt-get -f install. I read that people find a way to do this using Packages in the PPA, but it's not recommended because of the lack of security.
To insall java 8 on docker container, I used this command in dockerfile
RUN curl -LO 'http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.rpm'
-H 'Cookie: oraclelicense=accept-securebackup-cookie' RUN rpm -i jdk-8u111-linux-x64.rpm RUN rm jdk-8u111-linux-x64.rpm
It worked for awhile, but now this link is not no longer available. Is there replaceable url for this? or easy way to insall java 8 on docker?
It's up to your using OS, so I'd like you to show your OS. For example, Ubuntu users prepares their ppa repository for Oracle Java.
RUN add-apt-repository ppa:webupd8team/java
RUN apt-get update
RUN apt-get install oracle-java8-installer
It seems that Oracle has changed the authorization for downloading, the actual link that the browser uses is http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm?AuthParam=1496223138_c808095f7637d83147c37d69d3a87e7a, but this cannot be used with curl.
I have no solution for the problem with downloading from Oracle, but I use the official OpenJDK image as base and have found no problems with that.
If openjdk is OK for you, you can use
RUN apt-get install -y openjdk-8-jdk
openjdk, in contrast to oracle, does not require user's confirmation.
If you only need java runtime, consider openjdk-8-jre.
Adaption of my Dockerfile from https://hub.docker.com/r/sftech/java
FROM ubuntu
ENV JAVA_VERSION=8
RUN echo oracle-java${JAVA_VERSION}-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
RUN apt-get update \
&& apt-get install -y software-properties-common \
&& apt-add-repository ppa:webupd8team/java \
&& apt-get update \
&& apt-get install -y oracle-java${JAVA_VERSION}-installer \
&& update-java-alternatives -s java-${JAVA_VERSION}-oracle \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Why would you install java in an image / container, when you can get a java:8 image from the Docker store for free. The license requirements are exactly the same as the java / jdk download install from the oracle.com website.