Any installation location should work as long as you set the correct JAVA_HOME path and add the binary path to your $PATH variable.
You can configure both globally by editing /etc/environment
, which should take effect for all users after restarting your shell (you can shortcut that process by doing source /etc/environment
when testing).
JAVA_HOME=/usr/local/java/jre_10....
There should already be a PATH entry there which you can modify to add the Java binary directory.
This can differ between different Linux distributions and shell versions. If your distribution (Amazon Linux used it earlier at least) doesn't support it, you can use /etc/profile.
Another option that many prefer is to add an executable shell script in /etc/profile.d/ that sets up the variables for you, as these scripts are invoked on each initialization of a shell for all users.