gpt4 book ai didi

java - 带有Java 11和JavaFX Docker镜像的Zulu

转载 作者:行者123 更新时间:2023-12-02 18:13:41 25 4
gpt4 key购买 nike

我正在尝试基于Zulu OpenJDK 8宽度JavaFX和Maven设置Docker镜像。但是不幸的是JavaFX并不是debian二进制文件的一部分。

FROM azul/zulu-openjdk-debian:8u222

ARG MAVEN_VERSION=3.6.2
ARG SHA=d941423d115cd021514bfd06c453658b1b3e39e6240969caf4315ab7119a77299713f14b620fb2571a264f8dff2473d8af3cb47b05acf0036fc2553199a5c1ee
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries

RUN apt-get update \
&& apt-get upgrade -y \
&& mkdir -p /usr/share/man/man1 \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
&& rm -rf /var/cache/apt/archives/* \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz \
&& rm -f /usr/bin/mvn \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn


不幸的是,我无法构建基于JavaFX的应用程序:
[ERROR] /builds/myproject/java-clients/examples/javafx/src/main/java/com/myproject/demo/fx/DemoFxClient.java:[28,20] package javafx.scene does not exist

我也尝试过只使用openjdk docker镜像:
FROM openjdk:8-jdk-slim-buster

ARG MAVEN_VERSION=3.6.2
ARG SHA=d941423d115cd021514bfd06c453658b1b3e39e6240969caf4315ab7119a77299713f14b620fb2571a264f8dff2473d8af3cb47b05acf0036fc2553199a5c1ee
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries

RUN apt-get update \
&& apt-get upgrade -y \
&& mkdir -p /usr/share/man/man1 \
&& apt-get install -y --no-install-recommends \
openjfx \
ca-certificates \
curl \
git \
&& rm -rf /var/cache/apt/archives/* \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz \
&& rm -f /usr/bin/mvn \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn


是否有人能够创建支持JavaFX构建的Docker镜像?

最佳答案

我发现原来的问题不在于JavaFX设置,而是需要将JavaFX依赖项添加为maven依赖项。

带有Java FX和Maven Docker镜像的Zulu JDK 11 (例如,将在GitLab Pipeline中使用)

FROM debian:buster-slim

ARG MAVEN_VERSION=3.6.2
ARG SHA=d941423d115cd021514bfd06c453658b1b3e39e6240969caf4315ab7119a77299713f14b620fb2571a264f8dff2473d8af3cb47b05acf0036fc2553199a5c1ee
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries

# Install libraries used for builds
RUN apt-get update \
&& apt-get upgrade -y \
&& mkdir -p /usr/share/man/man1 \
&& apt-get install -y --no-install-recommends \
software-properties-common \
wget \
gnupg \
curl \
ca-certificates \
bzip2 \
zip \
unzip \
git \
&& rm -rf /var/cache/apt/archives/* \
&& rm -rf /var/lib/apt/lists/*

# Install Zulu 11
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xB1998361219BD9C9 \
&& apt-add-repository 'deb http://repos.azulsystems.com/debian stable main' \
&& apt-get update \
&& apt-get install -y --no-install-recommends zulu-11

# Install Maven
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
&& rm -f /tmp/apache-maven.tar.gz \
&& rm -f /usr/bin/mvn \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

# Add JavaFX
RUN curl -fsSL -o /tmp/javafx-11-0-2-sdk-linux.zip http://gluonhq.com/download/javafx-11-0-2-sdk-linux/ \
&& cd /tmp/ \
&& unzip /tmp/javafx-11-0-2-sdk-linux.zip \
&& cp -arf /tmp/javafx-sdk-11.0.2/lib/* /usr/lib/jvm/zulu-11-amd64/lib/

pom.xml
<project>
<!--- ... --->
<properties>
<maven.compiler.release>11</maven.compiler.release>
<javafx.version>11</javafx.version>
</properties>
<dependencies>
<!-- ... -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${maven.compiler.release}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>org.openjfx.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

这些StackOverflow问题/ CodeRepos很有帮助:
  • IntelliJ can't recognize JavaFX 11 with OpenJDK 11
  • https://github.com/openjfx/samples/blob/master/IDE/IntelliJ/Non-Modular/
  • 关于java - 带有Java 11和JavaFX Docker镜像的Zulu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58809122/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com