Issue
I'm trying to run a sample app on my android device with the following command :
sudo ionic cordova run android --device
I'm getting this error :
Failed to find 'JAVA_HOME' environment variable. Try setting it manually.
[ERROR] An error occurred while running subprocess cordova.
cordova build android --device exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
I already set the JAVA_HOME environment variable but that doesn't work .
~/Ionic/helloWorld$ echo $JAVA_HOME
/usr/lib/jvm/java-12-openjdk-amd64
Any recommendations ?
Solution
Your $JAVA_HOME
is pointing to the correct location. But the path should have $JAVA_HOME/bin
directory and not $JAVA_HOME
itself.
JAVA_HOME="/opt/jdk1.12.0"
export JAVA_HOME
PATH="$PATH:$JAVA_HOME/bin"
You should consider using the Oracle Java PPA instead. It usually does more than what a manual installation would do. You don't have to worry about setting up the environment variables either. That's what most people use.
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
Try running java -version and javac -version
to verify that the path is set.
Hope it helps.
Answered By - Saadat Sayem
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.