halcyon / asdf-java

A Java plugin for asdf-vm.
MIT License
454 stars 86 forks source link

asdf mvn fails with `The JAVA_HOME environment variable is not defined correctly` when system version is used #151

Open sirianni opened 3 years ago

sirianni commented 3 years ago
$ asdf exec mvn
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE

Debugging

++ source /home/sirianni/.asdf/plugins/maven/bin/exec-env
+++ asdf current java
++++ asdf where java
+++ export 'JAVA_HOME=System version is selected'
+++ JAVA_HOME='System version is selected'

It appears that this code be using should skip execution if the system version is in use.

#!/usr/bin/env bash
# if asdf provides java, then let's use that rather the system one (if at all avail)
if asdf current java > /dev/null 2>&1
then
    export JAVA_HOME=$(asdf where java)
fi