Selecting the verson of java from the command line

The place to discuss linux version of MakeMKV
Post Reply
Message
Author
bobthecat
Posts: 2
Joined: Sat Mar 18, 2017 8:41 am

Selecting the verson of java from the command line

#1 Post by bobthecat » Sun Jan 01, 2023 12:24 pm

Im running Ubuntu 22.04 and makemkv 1.17.2
I have several versions of java installed (via the apt package manager) and I have also manually installed oracle java 1.8 (usinbg these instructions https://docs.datastax.com/en/jdk-instal ... dkDeb.html).
My java directory looks like this:

Code: Select all

% ls -lh /usr/lib/jvm
total 12K
lrwxrwxrwx 1 root  root    21 Jul 22 09:44 java-1.18.0-openjdk-amd64 -> java-18-openjdk-amd64
lrwxrwxrwx 1 root  root    20 Oct 25 18:26 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64
drwxr-xr-x 7 root  root  4.0K Dec 31 22:28 java-18-openjdk-amd64
drwxr-xr-x 5 root  root  4.0K Dec 31 22:22 java-8-openjdk-amd64
drwxr-xr-x 7 10143 10143 4.0K Dec 15  2021 jre1.8.0_321
when I give the command 'java -version' i get:

Code: Select all

java -version
java version "1.8.0_321"
Java(TM) SE Runtime Environment (build 1.8.0_321-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.321-b07, mixed mode)
with the following plumbing in the background

Code: Select all

which java          
/usr/bin/java
 % ls -lh /usr/bin/java
lrwxrwxrwx 1 root root 22 Dec 31 22:22 /usr/bin/java -> /etc/alternatives/java
 % ls -lh /etc/alternatives/java 
lrwxrwxrwx 1 root root 34 Jan  1 09:54 /etc/alternatives/java -> /usr/lib/jvm/jre1.8.0_321/bin/java
so the default java executable links back to the java executable in jre1.8.0

'makemkvcon' defaults to using java-1.18.0-openjdk-amd64 (when nothing is specified in makemkv preferances > protection > Custom Java Executable Location) or, if something is specified -- whatever is specified

What I am trying to work out:
  1. is there any way from the command line makemkvcon to specify which version of java to use; and
  2. how does makemkv decide what the default version is?

keithhelms
Posts: 38
Joined: Sat Apr 16, 2016 10:34 am

Re: Selecting the verson of java from the command line

#2 Post by keithhelms » Sun Jan 22, 2023 4:34 am

The default version of java is decided by your path setting. if you enter "echo $PATH" you'll see that one of the directories in the list is /usr/bin. If you want makemkvcon to find a different version of java when you run it, you need to change the path so that it looks somewhere else first.

Let's say your path is currently
./:/home/myid/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
and you want makemkvcon to use a different version of java.

Here's an example that assumes that the 1.8 jre is installed at /data/jre1.8.0_291.

You could run PATH="./:/data/jre1.8.0_291/bin:/home/myid/bin:usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"

That would change the path for that terminal window as long as you have it open. If you want to change it just long enough to execute the makemkvcon command, you could do it in a subshell which just involves enclosing the commands in parenthesis

(PATH="./:/data/jre1.8.0_291/bin:/home/myid/bin:usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"; makemkvcon with whatever arguments)

Post Reply