Debian has a command that enables possibilities to choose a program from a list of programs that do something similar. The command
update-alternatives sets links to default programs for various operations.
To choose a default
java command from a list of installed JVMs one need to run as
update-alternatives --config java and choose the java edition to use.
java is not registered (installed) in alternatives subsystem you need to install it by using
update-alternatives --install "/usr/bin/java" "java" "/path/to/jdk" 1 .
From update-alternatives manual description of
--install link name path priority [--slave link name path]...
Add a group of alternatives to the system. link is the generic name for the master link, name is the name of its symlink in the alternatives directory, and path is the alternative being introduced for the master link. The arguments after --slave are the
generic name, symlink name in the alternatives directory and the alternative path for a
slave link. Zero or more --slave options, each followed by three arguments, may be
specified. Note that the master alternative must exist or the call will fail. However
if a slave alternative doesn't exist, the corresponding slave alternative link will
simply not be installed (a warning will still be displayed). If some real file is
installed where an alternative link has to be installed, it is kept unless --force is
edit summary: Answer edited to contain comments suggestions below by Manula Waidyanatha and Gilles - many thanks.