OS: Debian Stretch
Android Studio 3.4
JDK: open jdk 1.8
My Android studio build fails with following error:
Cannot find System Java Compiler. Ensure that you have installed a JDK
(not just a JRE) and configured your JAVA_HOME system variable to
point to the according directory.
I set JAVA_HOME, STUDIO_JDK etc and tried various tricks with openjdk , with no luck.
My default JRE is set to default as recommended
I am trying to update default JDK location as follow which given another error:
Already killed couple of hours to resolve this issue. So give android studio 3.4, my questions are:
What is wrong with the built-in compiler ?
Is openJDK 1.8 is valid jdk for android studio 3.4 to build/compile projects ? Or do I need Oracle-jdk?
I see oracle-jdk licensing has changed, can I use that for building commercial apps ?
Edit
I found later that the issue was , debian stretch installed jvm only. I tried to run javac -version which fails since by default stretch got jre only. Later I fixed by installing openjdk-8-jdk which fixed the issue:
sudo apt-get install openjdk-8-jdk
javac -version
javac 1.8.0_212
I had the same error and while i parsing google i found an interesting site.
In a lot of water i read the main information(in my opinion):
Android Studio requires Oracle Java 1.6 or later. It won’t work with OpenJDK.
I think we need to download oracle, becuase i see you are using java v 1.8 like me.
I didn't try that, but i think it will work.
Related
Still trying to get Eclipse IDE to work and running into Incompatible JVM error. I followed the steps here: I installed Java 7 but Eclipse keep saying that 1.6 is not suitable for this product
But unfortunately to no effect. Running OSX 10.9.5 and uninstalled the out-of-the-box version of Mac. The new version of Java seems to show up in the System Preferences. Please see attached screen capture. I've even done some of the basics like restart my computer, etc. Maybe there are other modifications I need to make to other files. I'm comfortable with Terminal but new to Eclipse and Java.
I have had the same problem as noted above. I could not get Eclipse to install because of Java incompatibilities. The sequence I followed goes like this:
Upgraded to MAC OS Sierra
Downloaded the Eclipse installer but was prompted that I needed to instal a legacy Java.
Installed Java 1.6
Was unable to install Eclipse and was prompted that I needed Java 1.7 or greater. Downloaded and installed Java 1.8
Ran the terminal code 'java -version' // this will check your jre version. This showed returned Java 1.6 despite the fact that I had upgraded to 1.8. The Java version listed in the Java control panel said 1.8
Tried multiple downloads of eclipse and Java and multiple restarts always with the same result.
Visited the Oracle web page noted above:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html I could not find the above reference to 8u73 and 8u74 but I did find and option to download 1.8.0_12. I did this. It installed without difficulty, and then I was able to install Eclipse without difficulty.
This took hours of my time. I hope this proves useful.
OK, so I don't really know what the problem was, but I simply fixed it by navigating to here http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html and installing 8u74 instead of 8u73 which is what I was prompted to do when I would go to "download latest version" in Java. So changing the versions is what did it in the end. Eclipse launched fine, now. Thanks for everyone's help!
edit: Apr 2018- Now is 8u161 and 8u162 (Just need one, I used 8u162 and it worked.)
JRE is a Run-Time Environment for running Java stuffs on your machine. What Eclipse needs is JDK as a Development Kit.
Install the latest JDK (and not JRE) from http://www.oracle.com/technetwork/pt/java/javase/downloads/jdk8-downloads-2133151.html and you should be good on Mac!
Open up terminal and check what java version is currently set in your path variable.
You can do that by typing in your terminal
java -version // this will check your jre version.
javac -version // this will check your compiler version
If this shows incorrect java version but you have installed java 1.8 then you have to set path variable to the newer version of java.
To do that do add the line:
export JAVA_HOME=/path/to/java/jdk1.x
to ~/.bash_profile (same as /Users/username/.bash_profile)
Then do this from the terminal to set the new variable
source ~/.bash_profile
Also what's your eclipse.ini set to ?
-Dosgi.requiredJavaVersion=1.7
EDIT:
Please open up terminal and type
find / -name "java" // This should find all folder named java on your file system.
Also how did you install java in the first place ?
Echoing the answer, above, a full install of the JDK (8u121 at this writing) from here - http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html - did the trick. Updating via the Mac OS Control Panel did not update the profile variable. Installing via the full installer, did. Then Eclipse was happy.
Here are steps:
download 1.8 JDK from this site
install it
copy the jre folder & paste it in "C:\Program Files (x86)\EclipseNeon\"
rename the folder to "jre"
start the eclipse again
It should work.
For some weird reason "Java SE Development Kit 8u151" gives this trouble. Just install, "Java SE Development Kit 8u152" from the following link-
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
It should work then.
I tried installing Android Studio, but I fail every time due to a JDK error.
Even when I select the requested path the installer still can't find it.
I have added the JAVA_HOME and JAVA_JDK variables with no luck.
Mind that when I open CMD and type java -version I get 1.7.0_79 and with the javac -version command I get 1.7.0_79.
Anything else I should try?
1.First open the Control Panel.
2.Uninstall every JDK you have installed.
3.Install JDK 1.7 or later.
4.Install Android Studio on the same drive where you installed JDK to.
I installed Java 8 SDK (with update 25 for JRE) from the Oracle Java site using the instructions on this page
http://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html
and put the following line in my ~/.bash_profile
export JAVA_HOME="/usr/libexec/java_home -v 1.8"
but when I try to compile or run a Java program in Bash I get the following message
No Java runtime present, requesting install.
and this window
I ran /usr/libexec/java_home to check:
$ /usr/libexec/java_home
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
But the JRE is in
/System/Library/Frameworks/JavaVM.framework/Versions/Current
and the JRE location in System Preferences is pointing to
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin
I don't know what the problem is here, but usr/bin/javac and /usr/bin/java are not able to find the correct JVM location in /System/Library/Frameworks/JavaVM.framework/Versions/Current.
I have encountered the same problem , i think you should install JDK but not JRE
You need to add some backticks:
export JAVA_HOME="`/usr/libexec/java_home -v 1.8`"
The /usr/libexec/java_home command outputs the right value for JAVA_HOME on its standard output, you need to use backticks to capture that value so you can store it in the variable.
But the JRE is in /System/Library/Frameworks/JavaVM.framework/Versions/Current
No, it isn't. The Oracle JRE installs itself under /Library/Internet Plug-Ins, the Oracle JDK installs under /Library/Java/JavaVirtualMachines. The binaries under /usr/bin and /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands are stubs that delegate to whichever JDK your JAVA_HOME variable points to.
Here's how I solved my problem on my mac
Check from RStudio if Java_HOME has been setup properly by running Sys.getenv("JAVA_HOME") in the console. If it returns blank, you need to set it up properly
Check whether you have Java SDK installed
Open terminal and check if you have Java SDK installed
Run the /usr/libexec/java_home -vcommand. This will show you the library where you Java SDK is installed.
If you don't have Java SDK installed yet, result from command above is blank, or the version is not up-to-date, download here and install the latest version.
Copy the library shown in step 2. On my mac, it shows:
/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
Back on your RStudio console, set the JAVA_HOME
Sys.setenv(JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home")
After doing the steps above, h2o.init() ran without hitch.
Please carefully note #Ian Robert's point on JRE vs JDK distinction. We need JDK to make h2o run.
I've tried several solutions, downloading several sdk but Android Studio didn't recognize them as valid sdks.
Finally, the workaround that worked for me was:
Delete Android Studio.app and Android Studio preferences (~/Library/Preferences/AndroidStuido).
Rename /usr/libexec/java_home to java_home.bak.
Install again Android Stuido.
When Android Studio prompts for a valid Java SDK, follow link provided by Android Studio and download that java installation.
After installation, push detect button on Android Studio, and run.
I'm using latest version of Eclipse Luna on Mac OS X 10.9.4. Whenever I try to open the Eclipse it says "version 1.6.0_65 of the JVM is not suitable for this product, version 1.7 or greater is required". I installed java 7 (JRE, I don't need JDK) but still I'm getting the same error. I tried java -version and the output was "java version 1.6.0_65". I can see the java icon on my system preferences. I also restarted my Mac to see if that works but that doesn't help either. I searched on google and some people suggesting other users to change Eclipse.ini file, the instructions wasn't clear and I'm a java beginner so I've no idea where and what to edit. Any step by step instructions will be appreciated.
I had this same problem with a fresh install of Eclipse Mars on OSX. I had installed the JRE from https://java.com/en/download/ (which is the top google search result for "java download" for me.
This failed for me with the same message "version 1.6.0_65 of the JVM is not suitable for this product, version 1.7 or greater is required"
Then I saw a comment that I should get the JRE/JDK from oracle instead:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
After downloading the most recent JDK from Oracle Eclipse starts fine.
A potential solution to your problem might be to uninstall Java6 (provided by Apple itself) and only have Java7 installed in your system. This only applies in case you have no applications that desperately need the old Java6 version to be installed.
To remove the Apple-like Java6 installation open a Terminal and:
sudo rm -rf /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
After this step you should only have Java7 by Oracle installed in your system. To verify, open another terminal and do a:
java -version
It should display something like "java version "1.7.0_XX" where XX is the current update version of the Java7 installation. If not: proceed with the next step.
Redefine the JAVA_HOME variable (to support IDEs like Eclipse and other developer tools...), which helps detecting where the "active" Java installation is situated in your system. Open a terminal and (Note: replace XX first!):
sudo rm /Library/Java/Home
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_XX.jdk/Contents/Home /Library/Java/Home
Afterwards, a fresh installation of Eclipse should detect Java7 in your system and should work with this version out of the box. You can modify an installed Eclipse to use this installation by navigating in Eclipse to:
Preferences -> Java -> Installed JREs. Then remove the old Java6 system entry AND add new path (see above) with the name Java7.
You can modify Info.plist inside Eclipse.app (right clic on Eclipse.app --> show package contents) and specify -vm after <key>Eclipse</key>.
For example :
<key>Eclipse</key>
<array>
<string>-vm</string><string>/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/bin/java</string>
<string>-keyring</string><string>~/.eclipse_keyring</string>
<string>-showlocation</string>
</array>
Ensure you installed the jdk 7 or above. If you have a Mac you most likely have 1.6.0.jdk. To check your java development kit (jdk) version go to the terminal and browse to:
/Library/Java/JavaVirtualMachines
Next, if you see 1.6.0.jdk then you did not install the latest version of the jdk. Go to http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html to install the latest jdk. Next use the browse out to the same file path aforementioned and ensure the latest jdk is in there (i.e. jdk1.8.0_141.jdk).
To specify Java 6 for OS X:
-vm
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java
For versions of Mac OS X 10.7+ the location has changed to
/Library/Java/JavaVirtualMachines/<''jdk_name_ver''>/Contents/Home/...
eclipse.ini > Specifying the JVM
Try any of these solutions
How do I run Eclipse using Oracle's new 1.7 JDK for the Mac?
Mountain Lion with Java 7 only
Eclipse still using java 6 as jre on Mac OSX
As I found out, we don't need to un-install an existing Java 1.6. Just installing or deploying a newer version 1.7 or 1.8, and setting the JAVA_HOME, along with the below given activities will solve the issue.
Check your c:/Windows/System32 (as I had this issue in windows). You will find junk java processes (java.exe, javaws.exe etc). Delete them all.
Deleting just java.exe will reflect in your PATH but eclipse still picks the javaws from c:/windows/system32. This is because, usually in PATH, you will have C:/Windows/System32 as the first entry. So, this will override any JAVA_HOME entry in the path.
Try starting the eclipse. It should work like charm! Atleast it did for me.
Try this
https://gist.github.com/johan/10590467
You might have to disable SIP and reenable it.
Okay so I have been struggling with this issue for a few days with Eclipse Neon and Oxygen. I was doing the below steps -
Check java -version from Terminal. It showed version as 1.7
Go to System Preferences -> Java -> Update Java version. Version 1.8 was downloaded and updated.
Went to Terminal again to confirm and this time it showed the version as 1.8.
But it still didn't work!! What was I missing now??
Here is what you need to keep in mind -- By default when you type the below command it shows the JRE version.
java -version
You need JDK to start your Eclipse installation. Please go to Java download page
and download the latest JDK version and you should be good to go.
Don't try to remove the Java in /System/Library/ - firstly this will not be allowed (you need to login as root user) and secondly you don't know the dependencies this Java version has on your other applications. Hope this helps!
Check your system variables ($JAVA_HOME specifically). This may be helpful:
http://www.mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/
Install the updated JDK
Update the environment variables: here's how
If still not working uninstall the older JDK
I see that you have installed the Java plugin and not the jdk. You can download the JDK from Oracle Downloads section.
You can remove the Java Plugin and install JDK from oracle downloads to resolve your issue.
I have had the same problem as noted above. I could not get Eclipse to install because of Java incompatibilities. The sequence I followed goes like this:
Upgraded to MAC OS Sierra
Downloaded the Eclipse installer but was prompted that I needed to instal a legacy Java.Installed Java 1.6
Was unable to install Eclipse and was prompted that I needed Java 1.7 or greater. Downloaded and installed Java 1.8
Ran the terminal code 'java -version' // this will check your jre version. This showed returned Java 1.6 despite the fact that I had upgraded to 1.8. The Java version listed in the Java control panel said 1.8
Tried multiple downloads of eclipse and Java and multiple restarts always with the same result.
Visited the Oracle web page. I could not find the above reference to 8u73 and 8u74 but I did find and option to download 1.8.0_12. I did this. It installed without difficulty, and then I was able to install Eclipse without difficulty.
I am trying to setup Android Studio on my Mac. It is running OSX 10.9.1 Mavericks. I have installed the latest JDK (at the time of writing 1.7 update 45), and I installed Android Studio. I use Java 7 because I have some Java applications I have to run and they require 1.7. I have not installed Java 1.6, because it is ancient and old. Launching Android Studio from any launcher does literally nothing. Activity Manager never shows it running. I do not want to install Java 1.6.
I did some work and tried to run the executable via command line through the package contents, and for both executables, I get these messages:
I am unsure what I am supposed to do to fix this error. I'm not very adept on a Mac (still somewhat new to it, and its confusing to do power user stuff on this) so if anyone can help me figure it out that'd be great. I'm on the 2013 Macbook Air with plenty of resources for this to run.
Update: This also applies to Yosemite, El Capitan, and all the other versions of OSX that can run Android Studio.
Update 12/11/2014
As of Android Studio 1.0 RC3 you can follow this set of directions to make it work.
I figured it out. You have to edit the android studio's Info.plist file in the package so it uses 1.7. I don't get why Android Studio insists we install and use an outdated, vulnerable version of Java.
Full resolution: http://i.stack.imgur.com/yyYaG.png
To open the package you need to find the Android Studio.app file in the Applications folder and right click it > Show Package Contents.
Edit the plist (I think you might need to be root) and change JVMVersion from 1.6* to 1.7* (or 1.8*, or whatever JDK major version you have). I don't get why that made a difference since my original output said it was using 1.7 anyways.
This fix seems to apply to all of IntelliJ's IDEs (I've seen it on PyCharm as well), though other ones seem to support newer versions of java natively.
As answered by hasternet # Android Studio was unable to find a valid Jvm (Related to MAC OS)
For quick and dirty solution, Follow the answer by Mgamerz; open Android Studio in Finder (CTRL+Click > Show Package Contests > Contents > info.plist) and edit Key JVMOptions>JVMVersion from "1.6*" to "1.6+"
Recommended method as discovered by Antonio Jose is to edit environment variables in MacOS (messing with info.plist is not recommended)
either at program launch (opening the Studio through terminal rather than the icon)
$ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
$ open /Applications/Android\ Studio.app
or setting up the environment through AppleScript at every MacOS startup:
do shell script "launchctl setenv STUDIO_JDK /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk"
do shell script "launchctl setenv STUDIO_PROPERTIES /Users/username/Library/Preferences/AndroidStudio/idea.properties"
do shell script "launchctl setenv STUDIO_VM_OPTIONS /Users/username/Library/Preferences/AndroidStudio/studio.vmoptions"
(Remember to save the script as Application. Antonio Jose managed with just the first line - AFAIK you can use .properties and .vmoptions to set up additional settings.)
Official instructions: http://tools.android.com/tech-docs/configuration/osx-jdk
(The reason why Android Studio want's to run off of JRE 1.6 is because it apparently makes the fonts look better - feel free to go through that "official" route and install JRE 1.6 # http://support.apple.com/kb/DL1572 - you can then set the JDK to 1.8 in the SDK Location settings - local.properties)
mgamerz is right - The release notes give a much better solution for rc3 and onwards - theres a idea.properties file
(or environment variable)
~/Library/Preferences/AndroidStudio/idea.properties
it also shows what environment variables you can use to set things like the jdk
export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk
ref : http://tools.android.com/recent/androidstudio1rc3_releasecandidate3released
I did below command on Mac Terminal to fix this problem, please make sure java version and path.
$java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
$ export STUDIO_JDK=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
$ open /Applications/Android\ Studio.app
Hey Friends I just Figured it out a simple way to fix this for Mac users.
Open Terminal and type this -> java -version and hit enter.
Output will be something like this:
Now check your Java Version. My Java version is 1.8
So now we need to Open Contents of our Android App.
For that right click the Android.app and then select Show Contents
Like this
Now there will be Content folder, Open that Folder and there you will find Info.plist
Open this info.plist
And you will see this.
In this expand the JVM
Here you will see the JVM version showing 1.6* but our jvm version is 1.8 (for example my jvm version is 1.8)
So we need to change this number according to our jvm version, so i changed it to version 1.8*
Then click save. And you are done.
Now you will see setup wizard running
And you are ready to start your first android programming app.
Here is the Whole Docx file for Android Studio Setup in Mac X
LINK: https://www.dropbox.com/s/9jwjebn5hgydyll/Android%20Studio%20Setup%20on%20Mac.docx?dl=0
I found that downloading an extra Java bundle from Apple fixed the issue.
If you search for this problem then I found the second link was to a blog having exactly this problem, all credit goes to him here
I know that posting links isn't an answer but as you can see from the resolution you need to make sure you have an up to date version of Java and also the Java bundle from Apple, for this reason I have also included the searches needed to get to these websites.
Here is where to download the latest version of Java
If this link is broken then searching "java latest version" return it at the top of the Google list
Here is where to download the Apple Bundle
If this link is broken then searching "Java for OS X 2014-001" returns it at the top of the Google list
For me trying to solve this problem it appears that initially it was an issue that required a work around and then Apple released an official work around download meaning that fiddling in plists is not necessary any more.