a year ago
10 14.95 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project attendance-system: Fatal error compiling: error: release version 21 not supported -> [Help 1]
How can I switch from Java 17 to Java 21? Is it not yet available?
3 Replies
a year ago
I recommend moving to building a docker image so that you're not relying on Railway to upgrade their build packs.
This is an example of a Dockerfile that builds an image for a Spring Boot 3.2 and JDK 21 app using Maven (comes from here: https://github.com/jitterted/format-hero/blob/master/Dockerfile)
FROM eclipse-temurin:21-jdk as build
COPY . /app
WORKDIR /app
RUN ./mvnw package -DskipTests
RUN mv -f target/*.jar app.jar
FROM eclipse-temurin:21-jre
ARG PORT
ENV PORT=${PORT}
COPY --from=build /app/app.jar .
RUN useradd runtime
USER runtime
ENTRYPOINT [ "java", "-Dserver.port=${PORT}", "-jar", "app.jar" ]
a year ago
Hello, I don't know if you solved this issue but I got the same and according to https://nixpacks.com/docs/providers/java you can override the default JDK version (17 as of today) with an environment variable called NIXPACKSJDKVERSION; in this case, its value should be 21. Hope you find this helpful!
a year ago
thanks!
variable NIXPACKSJDKVERSION:21 works fine