problem with javavm.sh

The man page says
Code:
     By default, [B]javavm[/B] will select the most "native" and up to date version
     of  the Java VM when a given symbolic link is used, invoking and passing
     the arguments to the matching executable within the chosen Java VM.

Code:
# pkg version | grep jdk
openjdk18-18.0.2+9.1_1             =
openjdk8-8.352.08.1_1              <

Code:
# java -version
openjdk version "1.8.0_352"
OpenJDK Runtime Environment (build 1.8.0_352-b08)
OpenJDK 64-Bit Server VM (build 25.352-b08, mixed mode)

I have java 18 installed, why is javavm insisting on using the ancient java 1.8 by default? The man page says it uses the latest version by default. I even tried removing 1.8 from /usr/local/etc/javavms, but it's still using it.

What am I doing wrong? (I only have 1.8 installed at all because javaservicewrapper package requires it as a dependency for some reason.)
 
I can confirm that having Java 11 and Java 18 installed javavm is still pointing to Java 11. But honestly I never use wrappers like javavm, *-alternatives.
In /usr/local/etc/javavms you have installation directories. Just prefix your PATH with /usr/local/openjdk18/bin/ and set JAVA_HOME to /usr/local/openjdk18/.
 
I even tried removing 1.8 from /usr/local/etc/javavms, but it's still using it.
That file doesn't determine the order but registers the available java VMs only. See registervm(1).

As 3301 already mentioned, one can set the JAVA_HOME environment variable to determine a specific version. See javavm(1) for other environment variables.

That variable can be set system-wide or per user.

System-wide, export the variable from /usr/local/etc/javavm_opts.conf (or /etc/profile for Bourne shell like, setenv for C shell like in /etc/csh.cshrc. Also from /etc/login.conf, shell independent ).

Per user, from the users log in shells configuration file.
 
Back
Top