Search This Blog

Friday, September 21, 2018

How to Set Default Java on CentOS

If you installed multiple versions of Java, you may want to set one as your default (i.e. the one that will run when a user runs the java command). Additionally, some applications require certain environment variables to be set to locate which installation of Java to use. This section will show you how to do this.
By the way, to check the version of your default Java, run this command:
java -version

Using Alternatives

The alternatives command, which manages default commands through symbolic links, can be used to select the default Java command.
To print the programs that provide the java command that are managed by alternatives, use this command:
sudo alternatives --config java