halcyon / asdf-java

A Java plugin for asdf-vm.
MIT License
467 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
aep-sunlife commented 3 weeks ago

I'm also seeing asdf fail to define JAVA_HOME, breaking Maven and Snyk.

Maven 3.3.9 Java Coretto 8 asdf 0.14.1 Oh Mh Zsh 4ad09ab zsh 5.9 macOS Sonoma