如何删除Java 10?React Native开发Java版本降级求助
How to Remove Java 10 and Install Java 8 for React Native Development
Hey there! I’ve been in your exact situation when setting up React Native—Java 8 is a hard requirement for building Android apps with RN, so let’s walk through removing Java 10 properly across different operating systems.
macOS Steps
- First, confirm your current Java version to make sure you’re targeting the right installation:
java -version - Head to the JVM installation directory:
/Library/Java/JavaVirtualMachines/- You’ll find a folder named something like
jdk-10.x.x.jdk—drag this to your Trash, or use the terminal to delete it permanently:sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-10*.jdk
- You’ll find a folder named something like
- Check for leftover environment variables: Open your shell config file (either
~/.bash_profile,~/.zshrc, or~/.profiledepending on your shell) and delete any lines that setJAVA_HOMEto the Java 10 path. - Install Java 8: Grab the official Java 8 JDK installer and follow the on-screen prompts to complete setup.
Windows Steps
- Open Control Panel > Programs > Programs and Features
- Locate
Java SE Development Kit 10in the list, right-click it, and select Uninstall - Clean up environment variables:
- Right-click This PC > Properties > Advanced System Settings > Environment Variables
- Under System Variables, find
JAVA_HOME—if it points to your Java 10 installation, delete it (you’ll set it to Java 8 later) - In the Path variable, remove any entries that point to Java 10’s
binfolder
- Restart your computer to apply changes, then install Java 8 using the official installer.
Linux (Ubuntu/Debian) Steps
- List all installed Java versions to confirm Java 10’s presence:
sudo update-alternatives --list java - Uninstall Java 10 packages:
- For OpenJDK:
sudo apt-get remove openjdk-10-jdk openjdk-10-jre - For Oracle Java:
sudo apt-get remove oracle-java10-installer
- For OpenJDK:
- Clean up unused dependencies:
sudo apt-get autoremove - Install Java 8 and set it as the default:
When prompted, select the number corresponding to Java 8 to set it as your default version.sudo apt-get install openjdk-8-jdk openjdk-8-jre sudo update-alternatives --config java
Final Check
After installing Java 8, run these commands to confirm everything is set up correctly:
java -version javac -version
Both should show a version starting with 1.8.x—that means you’re ready to start building React Native Android apps!
内容的提问来源于stack exchange,提问作者Vũ Nguyễn Duy
相关产品推荐
相关产品推荐

