'JAVA_HOME no change for ionic run android

I am developing in Ionic 4. I am using mac Mojave, and according to java -version, I am using 1.8.0_201, and $ JAVA_HOME also points to 1.8.0_201. However, when running ionic cordova run android, it gives me an android version error, because it indicates that I am using the JAVA_HOME of java 11.

Where is JAVA_HOME specified for ionic?

java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

$JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home

Error ...

cordova build android --device Android Studio project detected ANDROID_HOME=/Users/antoniodelgado/Library/Android/sdk JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home studio



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source