I am trying to build my Android app on the command line using Gradle commands. On executing the .gradlew build I am getting the error below:
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the location of your Java installation.
but I think I have already set the JAVA_HOME Path. If I echo %JAVA_HOME% in a separate cmd.exe window I get:
C:\Program Files\Android\Android Studio\jre
I have to point the JAVA_HOME to the JRE provided by Android and not the system Java, right?
Also, when I run the java command, it shows
'java' is not recognized as an internal or external command, operable program or a batch file
java -version
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) Client VM (build 25.271-b09, mixed mode, sharing)
Please clarify?
PATH environment variable must indicate to the \bin directory of your JAVA_HOME, for example they should look like this:
JAVA_HOME: "C:\Program Files\Java\jdk1.8.0_301"
PATH: "C:\Program Files\Java\jdk1.8.0_301\bin"
Note that the PATH variable has other values too and you must append your value to it.
I understood your problem, add your JDK (Not JRE) path to the PATH variable in environment variables. Then run the java command, and it should run. And whenever you post a question, please do make sure that you mention details like what happens when you run java command :)
I am trying to figure out how to sign apk with android debug key but when I use jarsigner after deleting meta from apk, I get the following error:
http://i.stack.imgur.com/ltOMv.png
Please help. I have java -version showing installed. Proof:
http://i.stack.imgur.com/gr1P8.png
I have Ubuntu 12.10 installed
You don't seem to have jarsigner binary in your path, which ships with Java Developer Kit (JDK), and probably not with Java Runtime Environment (JRE).
You should install JDK properly on your system, so that all required binaries are configured properly.
Install OpenJDK
Install Oracle JDK
Or If you have JDK in some other folder, you can add <JDK>/bin to $PATH environment variable:
export JDK_HOME=/path/to/jdk
export PATH=$PATH:$JDK_HOME/bin
I am using cygwin to build the cordova android project.
I created a project successfully
but there is some errors when I build it:
╭─Dozer#Dozer-PC ~/Projects/ba-crm/crm-plus ‹master*›
╰─$ cordova build 127 ↵
Running command: cmd args=["/c","C:\\cygwin64\\home\\Dozer\\Projects\\ba-crm\\crm-plus\\platforms\\android\\cordova\\build"]
ANT_HOME is set incorrectly or ant could not be located. Please set ANT_HOME.
But I have already install all the libraries in cygwin:
╭─Dozer#Dozer-PC ~/Projects/ba-crm/crm-plus ‹master*›
╰─$ ant -version
Apache Ant(TM) version 1.9.3 compiled on December 23 2013
╭─Dozer#Dozer-PC ~/Projects/ba-crm/crm-plus ‹master*›
╰─$ java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
╭─Dozer#Dozer-PC ~/Projects/ba-crm/crm-plus ‹master*›
╰─$ cordova -version
3.4.0-0.1.3
Just because the library is installed does not necessarily mean that the environment variable is set. To see if it's set, in Cygwin I believe you can do echo "$ANT_HOME".
Additionally as the error says, make sure it's set correctly. For example, on my machine ANT_HOME points to C:\Source\ANT\apache-ant-1.8.4.
Lastly, make sure your path is set up to have %ANT_HOME%\bin
export ANT_HOME=c:/path/apache-ant-1.9.4
(export ANT_HOME/cygdrive/c/path/apache-ant-1.9.4 fails - you need the :/ style)
I'm trying to start android development with Cordova on Ubuntu.
I can't add android platform for my project:
$ sudo cordova platform add android
Checking Android requirements...
[Error: ERROR : Make sure JAVA_HOME is set, as well as paths to your JDK and JRE for java.]
Environment checks:
$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
$ ant -version
Apache Ant(TM) version 1.8.2 compiled on May 18 2012
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/programs/adt-bundle/sdk/platform-tools:/programs/adt-bundle/sdk/tools
$ echo $JAVA_HOME
/usr/lib/jvm/jdk1.7.0_45
Eclipse ADT-Boundle is in /programs/adt-boundle folder
Please, tell me, why am I still getting this error?
[Error: ERROR : Make sure JAVA_HOME is set, as well as paths to your JDK and JRE for java.]
This got rid of the JAVA_HOME error for me:
~/.bashrc file:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
I also had to add:
export PATH=~/path/where/I/put/bundle/adt-bundle-linux-x86-20131030/sdk/tools
export PATH=~/path/where/I/put/bundle/adt-bundle-linux-x86-20131030/sdk/platform-tools
to get past another error
The error is simlar in Mac
I'm same bug
Checking Android requirements...
[Error: ERROR : Make sure JAVA_HOME is set, as well as paths to your JDK and JRE for java.]
https://issues.apache.org/jira/browse/CB-5422
After few days I tried cordova platform add android again and it worked good. Wery strange. I changed nothing.
I have installed Android Studio and I followed all steps described here
But when I start studio.sh I got an error with this message:
'tools.jar' is not in Android Studio classpath. Please ensure JAVA_HOME points to JDK rather than JRE
Can anyone here help me with this?
Check if your Java JDK is installed correctly
dpkg --list | grep -i jdk
If not, install JDK
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update && sudo apt-get install oracle-java8-installer
After the installation you have to enable the jdk
update-alternatives --display java
Check if Ubuntu uses Java JDK 8
java -version
If all went right the answer should be something like this:
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
Check what compiler is used
javac -version
It should show something like this
javac 1.8.0_91
Finally, add JAVA_HOME to the environment variable
Edit /etc/environment and add JAVA_HOME=/usr/lib/jvm/java-8-oracle to the end of the file
sudo nano /etc/environment
Append to the end of the file
JAVA_HOME=/usr/lib/jvm/java-8-oracle
You will then have to reboot, you can do this from the terminal with:
sudo reboot
In case you want to remove the JDK
sudo apt-get remove oracle-java8-installer
sudo apt-get install default-jdk
That's all in ubuntu 11
This is caused by having JAVA JRE installed as opposed to JAVA JDK.
The solution is simple:
sudo apt-get install openjdk-7-jdk
http://www.maxmakedesign.co.uk/development/2013/android-studio-tools-jar-classpath/
The error is self explanatory, you need to set your environment variable to JDK path instead of JRE here is it
JDK_HOME: C:\Program Files\Java\jdk1.7.0_07
check the path for linux
and here is possible duplicate Android Studio not working
Widows 7 64 bit.
JAVA_HOME point to my JRE (NOT JDK) directory
Coping of tools.jar from JDK\lib directory to ANDROIDSTUDIO\lib directory solve the problem
in OpenSuSE 13.1 and some 13.2 versions you also need to:
install java-1_7_0-openjdk-devel package
change the JAVA_HOME path when starting the studio:
For x86:
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0/ sh studio.sh
For x64:
JAVA_HOME=/usr/lib64/jvm/java-1.7.0-openjdk-1.7.0/ sh studio.sh
I had the same problem on a new installed Linux Mint 16. To fix this you just need to type command
sudo apt-get install openjdk-7-jdk
And that's it. You even do not need to add repositiries or creating JAVA_HOME in your environment.
On ubuntu I have tried all the methods that are described here but none worked.
What I did in the end was to:
download JDK from oracle, extract the archive
edit android-studio/bin/studio.sh and add at the top
export JAVA_HOME=/path/to/jdk
save the file and cd android-studio/bin and launch Android Studio: ./studio.sh
For me, running Fedora 22 with Gnome 16.2, this solution helped me.
In short, you should install the java-1.8.0-openjdk-devel, the development files of the JDK.
Open the Terminal and search for the latest version of the JDK development package:
$ dnf search jdk-devel
Last metadata expiration check performed 12:44:51 ago on Mon Aug 3 22:20:24 2015.
============================ N/S Matched: jdk-devel ============================
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-devel-debug.x86_64 : OpenJDK Development Environment with
: full debug on
$ sudo dnf install java-1.8.0-openjdk-devel
First check if the Java JDK is installed correctly:
dpkg --list | grep -i jdk
If not, install the JDK:
Download the latest version of the JDK from Oracle: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Extract it to the appropriate location in your machine. Get the extract location:
vi ~/.bashrc or vi ~./ bash_profile
JAVA_HOME=/home/user/installs/jdk1.7.0_40
PATH=$JAVA_HOME/bin
source ~/.bashrc or source ~/.bash_profile
After the installation you can check it:
java -version
which java
If all things are correct then the right the answer should be something like this:
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)
Append the following statement to studio.sh the file in android-studio/bin directory:
JAVA_HOME=/home/user/installs/jdk1.7.0_40
Finally start your Android Studio with the following command:
./studio.sh
The problem is a bug on Fedora 20. The bug is very odd: if I have Google Talk plugin installed then Eclipse crashes (https://bugs.eclipse.org/bugs/show_bug.cgi?id=334466). It's crazy for me. I thought that was Java version and with Java 6 my eclipse was still crashing. To solve this I should use gnome/GTK instead KDE. Now it works "well" (in gnome environment). Thanks for all answers.
I was facing similar problem on Windows 7 x64 professional edition. Please note following steps to fix this problem.
tools.jar is missing from required path if you are using jdk1.7 x64 bit version.
Please install x86 version of jdk1.7
Set JDK_HOME="C:\Program Files (x86)\Java\jdk1.7.0_67" and update path environment variable as path="C:\Program Files (x86)\Java\jdk1.7.0_67\bin"
Note: Linux put the proper path.
Launch 32 bit application from /android-studio\bin folder.
I tested and verified these steps on windows 7 with 32 bit jdk1.7
It's probably because you don't have jdk installed in your machine. I had exact same problem in first run. Open a terminal (CTRL+ALT+T) and type: sudo apt-get install openjdk-7-jdk
When done setup Java environment variable. Steps as follows:
sudo gedit /etc/environment
Either in the beginning or end of the file write: JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386 (location may vary depending on the installation of your Java)
export JAVA_HOME
save and exit editor.
Load the path variable again using the terminal: . /etc/environment
Couple of helpful links for further clarifications:
How to install JDK on Ubuntu (Linux)?
How to set JAVA_HOME for OpenJDK?
Hope this helps.
On Windows 7 just run the studio.bat file in your android-studio/bin folder with right click as an administrator. Now you get ask to import previous studio settings. Ignore this and on the next dialog you can specify the path to your jdk directory.
That's all.
Marcel
I ran into this issue when I was referencing
[drive]:\Program Files\Java\jdk1.8.0_65
in my JAVA_HOME environment var instead of the Android Studio recommended
[drive]:\Program Files\Java\jdk1.7.0_79.
I am using the x64 version of the JDK on Windows 10 Pro.
From the Android Studio installation instructions.
Before you set up Android Studio, be sure you have installed JDK 6 or higher (the JRE alone is not sufficient)—JDK 7 is required when developing for Android 5.0 and higher. To check if you have JDK installed (and which version), open a terminal and type javac -version. If the JDK is not available or the version is lower than version 6, download the Java SE Development Kit 7
http://developer.android.com/sdk/installing/index.html?pkg=studio
You have 2 things you must check:
verify that /etc/environment file has the correct JAVA_HOME and PATH values referring to your Java installation directory.
verify that you have the correct Java version (maybe you are using a distribution of Linux which need a server version of Java) you may need this version like my case JRE for server.
On my Linux Mint 17.3 install, I found these instructions incredibly helpful.
The problem seems to boil down to the system's default Java being OpenJDK and Android Studio preferring Oracle's JDK. I actually did not perform the OpenJDK removal steps given in the tutorial, but only downloaded the Oracle JDK and set it as my system's default. Android Studio worked right away.
In case the linked page ever goes away, the steps I took were
Download Oracle JDK. Mine was version 1.7.0_79.
tar -zxvf jdk-7u79-linux-x64.tar.gz
sudo mkdir -p /opt/java
sudo mv jdk1.7.0_79 /opt/java
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.7.0_79/bin/java" 1
sudo update-alternatives --set java /opt/java/jdk1.7.0_25/bin/java
and
java -version
confirms the system is using Oracle's JDK, giving output like
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)