I downloaded and installed the JDK+Netbeans bundle from the Oracle website, but when I type java -version
at the terminal, I get this output:
$ java -version
The program 'java' can be found in the following packages:
* default-jre
* gcj-4.8-jre-headless
* openjdk-7-jre-headless
* gcj-4.6-jre-headless
* openjdk-6-jre-headless
Try: sudo apt-get install <selected package>
Firstly, what does this mean? Are there multiple versions of java installed on my system?
Secondly, there is a JDK folder that got created after I installed Netbeans+JDK. These are the contents of the folder:
$ pwd
/usr/local/jdk1.8.0_65
$ ls
bin javafx-src.zip man THIRDPARTYLICENSEREADME-JAVAFX.txt
COPYRIGHT jre README.html THIRDPARTYLICENSEREADME.txt
db lib release
include LICENSE src.zip
Thirdly, Android Studio isn't able to find JDK_HOME
even though I gave export JDK_HOME=/usr/local/jdk1.8.0_65
in bashrc
. What could be done?
I'm considering deleting the jdk1.8.0_65
folder and using sudo apt-get install default-jre
and sudo apt-get install default-jdk
, but am apprehensive if deleting the jdk folder would mess up something, or whether the apt-get
commands would download the latest version of Java.
UPDATE:
Tried adding the bin
folder to PATH
, but although the java version is being shown properly, android studio isn't able to find the JDK.
$ echo $PATH
/usr/local/jdk1.8.0_65/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
$ java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
$ android
[sudo] password for nav:
ERROR: Cannot start Android Studio
No JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation.
$ echo $JAVA_HOME
/usr/local/jdk1.8.0_65/bin
$ echo $JDK_HOME
/usr/local/jdk1.8.0_65
$
What you are missing is adding
jdk1.8.0_65/bin
folder to your PATH environmental variable.No, but the one you installed in
/usr/local/jdk1.8.0_65
isn't located by other programs likenetbeans
orandroid
that depend on Java. To verify it for yourself, just open up your terminal and add the folder containingjava
executable to your path variable like this:To test whether this was successful, go to any directory and fire this command:
Once that is a success, go to netbeans folder and execute it:
If all other settings are good, it should run and so should android! To make the changes permanent, add the path modifier to your
~/.profile
file (otherwise, you will have to issue theexport
command each time you open the terminal to work with java).No, these are package options to install to get java. You have currently chosen to install outside the package system.
It is simplest to use the package-supported versions of java if you can. This way you can simply update your packages, rather than having to install another JDK and change all of your pointers to the new version.
At this time, you need Java 7 to develop with Android Studio. http://developer.android.com/sdk/installing/index.html?pkg=studio https://stackoverflow.com/questions/23318109/is-it-possible-to-use-java-8-for-android-development