Created: April 5, 2022 9:38 AM
Tags: java, jhipster, spring
In this short article, I’ll explain how to run and deploy a JHipster project using another version than the standard version which is used by JHipster (Java 11 currently).
Firstly, you need to have the targeted Java version on your local environment. If you are using SDK man you can run:
sdk list java
- Once you have found the target version inside, install it with
sdk install java 17.0.2-open(for instance)
- Finally, run
sdk use java 17.0.2-opento use it in your current terminal
💡 SDK man is a great tool to manage multiple Java versions on your environment. It allows to easily install versions and switch between versions
Once you are using the right Java version locally, you just have to change the target release in the project. If you’re using Maven, you just need to change
<java.version>17</java.version> in the
🎉 You are now ready to go, you can try to run the project with
💡 If you see an error saying “Invalid target release 11”, it’s probably that your local and project version are out of sync. They have to be the same (17 in my use case)
If you are using a CI and your CI is using the
jhipster/jhipser:latest Docker image to run the project and the tests, it won’t work anymore because this Docker image is based on
eclipse-temurin:11-jre-focal which is using Java 11.
It means that you will have to recreate your own Docker image based on Java 17, but don’t worry, it’s not complicated:
- Clone the generator-jhipster project on Github
- Open the Dockerfile which is at the project’s root
- Edit the base image to
- Create a repository on the docker hub. Let’s assume it’s called
- Build the new image with
docker build . -t myOrganization/jhipster-java-17:latest
- Push the brand new image to the hub with
docker push myOrganization/jhipster-java-17:latest
- Finally, change the docker image used in your CI to
myOrganization/jhipster-java-17:latestand when your CI reruns, it will succeed.
You’re done, your JHipster project should now run on Java 17 🎉
If you don’t use JHipster yet, you can learn how to generate your first project with JHipster with this article (which is in French).