The scenario is 1 system user that is running multiple java services that require different java versions... yes it is a Minecraft server... minecraft 1.17+ requires a different version so I need to find a way to have 3 servers running java 11 and 1 server running on java 17 at least... I have been told to use JAVA_HOME but everything I have looked up doesn't make sense to me... I'm running the server as a systemd so it has a service file in /etc/systemd/system. here is what one looks like.
[Unit]
Description=start and stop the RENAISSANCE minecraft-server
After=network.target
Before=builder.service skyblock.service hardcore.service
[Service]
Type=idle
WorkingDirectory=/opt/minecraft/server/renaissance
UMask=002
User=minecraft
Group=minecraft
Restart=always
RestartSec=20 5
Nice=1
KillMode=none
SuccessExitStatus=0 1
ProtectHome=true
ProtectSystem=full
PrivateDevices=true
NoNewPrivileges=true
ExecStart=/usr/bin/java -Xms3G -Xmx6G -jar renaissance.jar nogui
ExecStop=/opt/minecraft/tools/mcrcon/mcrcon -H 127.0.0.1 -P 25596 -p ******* stop
[Install]
WantedBy=multi-user.target
Where I really get lost in all the links that are in the /usr/bin/java I follow it all out to /usr/lib/jvm here is where it gets the specific version of java and I can change that with the command:
update-alternatives --display java
but this changes it for everyone to use all the time. I need one service to use java 17+. How do I properly accomplish this? I also understand the new "proper way" is in my /etc/systemd/system directory that I should be using a someservice.conf file and that is possibly where this should occur. I'm using ubuntu 20.04 if that helps any.