Skip to content

Commit

Permalink
Install Java 21 on docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
3arthqu4ke committed Jul 18, 2024
1 parent 775c4e1 commit d9e9673
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@

# TODO: download HMC-Specifics?
FROM openjdk:17.0.2-jdk as java17
FROM openjdk:21-jdk as java21
FROM openjdk:8u332-jdk

COPY --from=java17 /usr/java/openjdk-17 /usr/java/openjdk-17
COPY --from=java21 /usr/java/openjdk-21 /usr/java/openjdk-21

# For some reason the jdk17 image does not come with any certificates, which causes problems
RUN cp --remove-destination /usr/local/openjdk-8/jre/lib/security/cacerts /usr/java/openjdk-17/lib/security/cacerts
RUN cp --remove-destination /usr/local/openjdk-8/jre/lib/security/cacerts /usr/java/openjdk-21/lib/security/cacerts

COPY . /headlessmc
WORKDIR /headlessmc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class JavaVersionParser {

private static final Pattern PATTERN = Pattern.compile(
"version \"(\\d+)[.-](\\d*)");
"version \"(\\d+)[.-]?(\\d*)");

public int parseVersionCommand(String path) throws IOException {
Process prcs = new ProcessBuilder().command(path, "-version").start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ public void testParse() throws IOException {
"internal+0-adhoc..src)");
Assertions.assertEquals(17, version);

version = parser.parseVersion(
"openjdk version \"21\" 2023-09-19\n" +
"OpenJDK Runtime Environment (build 21+35-2513)\n" +
"OpenJDK 64-Bit Server VM (build 21+35-2513, mixed mode, sharing)");
Assertions.assertEquals(21, version);

Assertions.assertThrows(IOException.class,
() -> parser.parseVersion("test"));
}
Expand Down
2 changes: 1 addition & 1 deletion headlessmc-scripts/HeadlessMC/config.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# suppress inspection "UnusedProperty" for whole file
# This config is for the docker container.
hmc.gamedir=/headlessmc/headlessmc-scripts/HeadlessMC/run
hmc.java.versions=/usr/local/openjdk-8/bin/java;/usr/java/openjdk-17/bin/java
hmc.java.versions=/usr/local/openjdk-8/bin/java;/usr/java/openjdk-17/bin/java;/usr/java/openjdk-21/bin/java
hmc.invert.lwjgl.flag=true
hmc.invert.pauls.flag=true
hmc.store.accounts=true
Expand Down

0 comments on commit d9e9673

Please sign in to comment.