logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Login


Options
View
Go to last post Go to first unread
qiu  
#1 Posted : Monday, September 05, 2022 9:17:00 AM(UTC)
qiu

Rank: Advanced Member

Groups: Registered
Joined: 9/5/2022(UTC)
Posts: 63
China
Location: manhudun

Java is one of the most popular programming languages ​​used to build various applications and systems. There are two different implementations of Java, Oracle Java and OpenJDK. Among them, OpenJDK is an open source implementation of the Java platform. Oracle Java has some other commercial features and is licensed for non-commercial use only. Here's how to install Java (OpenJDK) on Raspbian OS on Raspberry Pi.

Run the following command to install the latest JDK version, currently the OpenJDK 11 JDK:
sudo apt update
sudo apt install default-jdk
After the installation is complete, you can verify the Java version by checking the command:
java -version
output:
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-post-Raspbian-1deb10u1)
OpenJDK Server VM (build 11.0.5+10-post-Raspbian-1deb10u1, mixed mode)
Install Java 8
Java 8 is still widely used today. If you need Java 8, the installation command is:
sudo apt update
sudo apt install openjdk-8-jdk
Check the Java version:
java -version
Multiple Java versions do not conflict. If you need to set the default version, you can use the following method. Run the java -version command to confirm the default version. If you need to modify the default version, you can use the update-alternatives tool:
sudo update-alternatives --config java
You will see the installed version of Java.
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status

* 0 /usr/lib/jvm/java-11-openjdk-armhf/bin/java 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-armhf/bin/java 1111 manual mode
2 /usr/lib/jvm/java-8-openjdk-armhf/jre/bin/java 1081 manual mode

Press to keep the current choice
  • , or type selection number:
    Enter the version number of the default version you want to set and press Enter.
    If you have multiple JDK versions installed, to set the JAVA_HOME environment variable, you need to edit the /etc/environment file:
    sudo nano /etc/environment
    Assuming you want to set JAVA_HOME to OpenJDK 11, you can add at the end of the file:
    JAVA_HOME="/usr/lib/jvm/java-11-openjdk-armhf/bin/java"
    The following path is what the update-alternatives command outputs.
    Then run the command:
    source /etc/environment
    Finally, to uninstall the default-jdk package, just run:
    sudo apt remove default-jdk

    PI-SUPPLY is a professional component supplier, providing everything you need for your component project. We also stock a huge selection of Raspberry pi, Arduino, micro:bit, rock pi and nvidia manufacturer accessories from your favorite brands.
  • Users browsing this topic
    Guest
    Forum Jump  
    You cannot post new topics in this forum.
    You cannot reply to topics in this forum.
    You cannot delete your posts in this forum.
    You cannot edit your posts in this forum.
    You cannot create polls in this forum.
    You cannot vote in polls in this forum.