JAVA_HOME
030 opened this issue · comments
After installing 14, the JAVA_HOME is not set. Could you set the JAVA_HOME?
./gradlew b
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-8-openjdk-amd64
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
@030 Thanks for raising this issue, but this role already sets the JAVA_HOME
environment variable. Unfortunately, there are multiple ways of doing this in Linux each with their own advantages and disadvantages.
The technique this role uses is to create a shell script under /etc/profile.d
(/etc/profile.d/java.sh
); the advantage of this technique is it involves creating a new file (rather than modifying an existing file - which is more error-prone and more likely to cause upgrade issues). The disadvantage is this technique is it only works if you run the profile initialization. Your bash profile typically gets initialized when you run bash --login
or source /etc/profile
. Most of the time this is done for you, but depending on how you run your shell it may not be.
If you're using Java for development I suggest you use SDKMAN!, it makes installing and switching between Java versions very easy. I have another Ansible role for installing SDKMAN! gantsign.sdkman.