Forum Discussion
manish2501345
Sep 02, 2024Copper Contributor
Best Practice to build multiple application using different java version with Single Agent
Hello,
I had an java application with tech stack such as gradle, java11 etc. I configured an agent with all required tools including java 11 to build the app. It worked fine.
Recently for a new java application which uses java17, I used the same agent and installed java17 on that.
Build for this application worked fine but I noticed that old application build which require java 11 started getting failed along with ./gradlew commands
When I checked on the agent, JAVA_HOME was correctly pointing to JAVA11 but java -version was set to java17. Also gradle 6.7 version is set to use java11.
I am pretty sure that issue is due to java version conflicting or mismatch but I want to understand on best practices to follow:
- is it ok to use same agent server for different application (which required different java versions) or in other terms is it ok to install multiple java versions on same agent server
- if it's fine how to make sure the applications are using the expected java version. I have already set the toolchain to use respective java version in build.gradle of application itseld but still ./gradlew addCredentials is failing for the same commit which was successful before I installed java 17 and used the same agent for another application.
Please suggest.
1 Reply
Sort By
Refer this on manage multiple Java versions on the same machine:
Multi-Module Project with Maven | Baeldung