简体   繁体   中英

How to install Java(openjdk) on Ubuntu for React-native

I tried install open-jdk for react-native.But i encountered some problem. How can i solve it ? Thanks

$ sudo apt update 
$ sudo apt install default-jdk

Reading package lists... Done
Building dependency tree       
Reading state information... Done
default-jdk is already the newest version (2:1.11-68ubuntu1~18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
5 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up oracle-java11-installer-local (11.0.4-1~linuxuprising1) ...
Before installing this package,
please download the Oracle JDK 11 .tar.gz file
with the same version as this package (version 11.0.4),
and place it in /var/cache/oracle-jdk11-installer-local,

E.g.:
sudo mkdir -p /var/cache/oracle-jdk11-installer-local
sudo cp jdk-11.0.4_linux-x64_bin.tar.gz /var/cache/oracle-jdk11-                        
installer-local/
sha256sum mismatch jdk-11.0.4_linux-x64_bin.tar.gz
Oracle JDK 11 is NOT installed.
dpkg: error processing package oracle-java11-installer-local (--                    
 configure):
 installed oracle-java11-installer-local package post-installation         
script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of default-jre:
 default-jre depends on openjdk-11-jre; however:
  Package openjdk-11-jre is not installed.
  Package oracle-java12-installer which provides openjdk-11-jre is 
  not         
 installed.
  Package oracle-java11-installer-local which provides openjdk-11-jre     
  is not configured yet.

 Errors were encountered while processing:

 oracle-java11-installer-local
 default-jre
 default-jdk
 default-jre-headless
 default-jdk-headless

 E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried remove java and java's repo and re-install but no response. Sorry my English.

Edit

If i run this code:

java -version

give the output:

openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03- 
0ubuntu1.18.04.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)

I don't use Java with Android Studio.

Try these commands:

add repository

sudo add-apt-repository ppa:openjdk-r/ppa

update the packages

sudo apt-get update

Install OpenJDK 8:

sudo apt-get install openjdk-8-jdk

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM