title: Error "the JAVA_HOME environment variable is not defined correctly" on running "mvn clean javadoc:jar package"
body: <p>When I try to execute the command</p>
  <p><code>mvn clean javadoc:jar package</code></p>
  <p>it shows</p>
  <blockquote>
  <p>the JAVA_HOME environment variable is not defined correctly. This environment variable is needed to run this program.</p>
  </blockquote>
  <blockquote>
  <p>NB: JAVA_HOME should point to a JDK, not a JRE.</p>
  </blockquote>
  <p>I checked out the already asked question <em><a href="https://stackoverflow.com/questions/13961615/unable-to-find-javadoc-command-maven">Unable to find javadoc command - maven</a></em> and the solution I tried above were taken from this solution only. I am new to Ubuntu. How can I fix this?</p>
  <p>Whereas when I run <code>echo $JAVA_HOME</code> it prints:</p>
  <pre class="lang-none prettyprint-override"><code>/usr/lib/jvm/java-11-openjdk-amd64
  </code></pre>
  <p>I also tried setting the <code>JAVA_HOME</code> to:</p>
  <ol>
  <li><code>/etc/launchd.conf/java-11-openjdk-amd64</code></li>
  <li><code>/usr/libexec/java-11-openjdk-amd64</code></li>
  <li><code>/usr/libexec/java-11-openjdk-amd64/</code></li>
  </ol>
  <p>When I run <code>mvn -v</code>, it prints:</p>
  <pre class="lang-none prettyprint-override"><code>Apache Maven 3.6.3
  Maven home: /usr/share/maven
  Java version: 11.0.10, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
  Default locale: en_IN, platform encoding: UTF-8
  OS name: &quot;linux&quot;, version: &quot;5.8.0-45-generic&quot;, arch: &quot;amd64&quot;, family: &quot;unix&quot;
  </code></pre>
  <p>And when I run <code>echo $JAVA_HOME</code> it prints:</p>
  <pre class="lang-none prettyprint-override"><code>/usr/lib/jvm/java-11-openjdk-amd64
  </code></pre>