How do I run a specific program that requires a different version of Java without changing the default system version of Java?

I am using Ubuntu Server to host multiple Minecraft servers. For the latest versions of Minecraft, I need the latest version of Java; however, I would like to run a modded server as well and some of the mods are incompatible with the newest version of Java. How can I run the modded server using Java version 15 while running the other servers using the newest version? I am fairly new to Ubuntu Server so any help would be much appreciated.


Solution 1:

I believe you could run the java executable located in (I think) /usr/lib/jvm/java-(version)-(vendor)/bin/java the same way you'd just use the java link.

You'd still need to install the correct jvm version.