Running OSX 10.15.7, sdkman 5.9.1+575.
sdkman seems to have gotten into a bad state where it thinks Java 1.8 both is and is not installed.
$ sdk uninstall java 1.8.0 /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/
java 1.8.0 is not installed.
$ sdk install java 1.8.0 /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/
java 1.8.0 is already installed.
$ ls /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk
ls: /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk: No such file or directory
Java 1.8 was installed through sdkman and working fine, then I ran a blanket brew upgrade and I think it tried to upgrade my Java version. I am not 100% that this is the cause - it was about a week ago and that terminal session is long gone, and ~/Library/Logs/Homebrew/openjdk is empty.
How can I get sdkman unstuck, or how can I uncover more information about what's wrong?
I cross-posted this in the sdkman slack channel and got a solution. Posting here for posterity.
My mistake was using SDKMAN to coordinate the brew installed version of Java. Apparently this is very cumbersome, and will break every single time that brew releases a new version of that JDK.
Steps to resolve:
$ unlink ~/.sdkman/candidates/java/1.8.0
$ sdk install java 8.0.282.j9-adpt
This disconnects sdkman from the brew version of Java, and adds a parallel installation of Java 8.
I'm working on MacOS and just starting with react-native.
One of the first steps to get started is to run: react-native run-android or react-native run-ios. But I'm getting this error:
react-native run-android
Result:
Scanning folders for symlinks in /Users/ric/myprojs/albums/node_modules (6ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine java version from '9.0.1'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
This is what I get when I run java --version:
java --version
Result:
java 9.0.1
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
mbp:albums ric$ java --version
java 9.0.1
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
Edit
My javac version:
javac --version
Result:
javac 9.0.1
Any idea on how to fix this?
In your PROJECT_PATH/android/gradle/wrapper/gradle-wrapper.properties file, update your distributionUrl to the following:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
See related gradle distributions documentation
Really the fastest way to get around this error is to use JDK 8. Except when you really need to use JDK9.
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Don't forget to change your enviroment variable JAVA_HOME to the new JDK version!
Make sure that you have JDK8 installed and then set JAVA_HOME into JDK8
for example:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
or use .bash_* files to set this variable
vi ~/.bash_profile
Then add the following lines:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
Now source the file to make the above changes effective in the current shell:
source ~/.bash_profile
On MacOS, I ran the following commands:
brew cask uninstall java
brew tap caskroom/versions
brew cask install java8 "or just brew cask install java to install latest version"
I was getting this error, but for a more recent version of Java - 10.0.2.
To fix my error, I followed the steps mentioned by #Blacktoviche in this Github issue: https://github.com/facebook/react-native/issues/17688
When I opened the android folder inside my project via Android Studio, I was prompted with Android Gradle plugin update recommended. At the time, I was following a slightly outdated tutorial that told me to click Don't remind me again for this project.
However, as #Blacktoviche recommended in the github issue linked above, sometimes it's necessary to update the Gradle plugin. After updating, I also had to click Install Build Tools 27... and sync project (I don't remember the exact version).
After I followed these steps, I was able to successfully run my react native app on the Android Studio emulator.
Hope this helps someone!
---- December 2018 --- keep attention ---
React Native does not work with Java versions higher than 8, so you need to uninstall your 9.0.1 version. To do so, execute the following commands:
cd /Library/Java/JavaVirtualMachines/
ls -l
Identify the folder containing your Java Version, then remove it
sudo rm -rf jdk.x.x_xxx.jdk
After that you can download and install java 8 from oracle again. Refer to jdk8 download page
If you are using windows; Make sure you add your jdk path to the Environment path variable.
Then open your android folder from your react native project into android studio. It will update necessary things for you automatically.
I usually get this error when I forget to build the project using Android Studio. A simple sync and upgrading Gradle will do the work.
I solve this by downgrading my JDK to 8.
On Ubuntu, you should run these command lines in the terminal:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt install oracle-java8-installer
sudo apt install oracle-java8-set-default
I use IntelliJ IDEA Ultimate 2017.3.3 and need to use Scala Version 2.12 for a project. However, IntelliJ says that JDK 1.8 is required for Scala Version 2.12. My problem is that I cannot select/choose JDK 1.8. Hence How can I set/install JDK to 1.8?
Any help is heavily appreciated.
Here you can download the Java JDK 1.8. After installing it, it should appear as an option inside IntelliJ.
UPDATE:
Find File -> Project structure menu and go to Project Settings -> Project tab. If on Project SDK the Java version 1.8 SDK is not selected, change it and click OK.
In 2022, you can use just brew
brew install openjdk#8
and then add into Intellij IDEA as new SDK with the following path:
/usr/local/opt/openjdk#8
maybe you need to update PATH env:
export PATH="/usr/local/opt/openjdk#8/bin:$PATH"
…and for the future give a try to sdkman, is better than brew
curl -s "https://get.sdkman.io" | bash
then open a new shell and try list to see what you could install ;-)
sdk list java
At time of writing you could use:
sdk install java 8.0.312-tem
2023 on Mac chip only brew install --cask adoptopenjdk8 and then use in terminal vim ~/.zshrc with export JAVAC_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/ inside that file.
I'm trying to install mysql on my Mac using the command
sudo apt install mysql
and it said I needed to install JDK on it. So I installed JDK but am receiving an error saying:
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/bin/apt" (-1)
I have updated my env path to
JAVA_HOME=/Library/Java/Home
But when I install JDK theres no java file anywhere in my library, even though when I check to see if I have installed it, it is successfully found. I've installed Homebrew but do not know what package to install after the initial installation, or if this is the problem.
Any help would be appreciated.
If you are using Mac it would be much easier to install Homebrew from https://brew.sh and then use $ brew install mysql
see this link for the apt and yum command usage
When I originally installed Android Studio, I had it with JDK 1.7. Now JDK 8 is required to build for Android N, so I installed it. I tried redirecting the project structure to the JDK 1.8 install, but every time I push OK, it automatically goes back to JDK 1.7. Am I missing something here on updating JDK?
You need to set the default JDK, if you just installed the 1.8
(most cases) you now have the 1.7 and the 1.8 installed.
if you want make sure what java you are using as default run the command.
javac -version
and
java -version
if is a old version you can set using the command (for Debian base Linux).
sudo apt-get install oracle-java8-set-default
PS: sorry if you are using Windows I'm not able to help you,
and next time will nice to know which OS are you using .