Score:5

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

eg flag

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.

cocomac avatar
cn flag
Why not just have multiple versions of Java installed? If you need something complex, you could also use Docker if you wanted a more complex setup.
lordoftimelords avatar
eg flag
@cocomac I have multiple versions of Java installed; however, when you use the `java`command it defaults to the system default jdk does it not? I'm new to this so maybe I'm wrong.
Score:5
cn flag

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.

lordoftimelords avatar
eg flag
How would I do that? Sorry if this is a stupid question. Can I run multiple versions by adding something to the command to start the server? Almost like adding a command-line argument? I'm sorry, I don't follow.
cn flag
Instead of doing `java -jar minecraft.jar`, you'd just replace the `java` with the path of the java 8 executable, for example with OpenJDK 8, `/usr/lib/jvm/java-8-openjdk/bin/java -jar minecraft.jar`
Redbob avatar
in flag
You could java anywhere you have downloaded it, not just `/us/lib/jvm`. Just run `/anywhere/bin/java -jar minecraft.jar`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.