How to permanently set JAVA_HOME on Ubuntu

featured image

If a project needs the JAVA_HOME variable pointing to a particular value and this requirement is not met on our environment, we will get errors while trying to build that project, e.g. the “Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set” error. Instead of exporting the JAVA_HOME value manually we can easily set the variable permanently with a custom script.