OpenJDK 17 : स्थापित करें2023/09/21 |
OpenJDK 17 स्थापित करें।
|
|
[1] | OpenJDK 17 स्थापित करें और एक परीक्षण प्रोग्राम चलाएँ। |
root@dlp:~#
apt -y install openjdk-17-jdk
root@dlp:~#
cat > /etc/profile.d/java.sh <<'EOF'
export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which java))))) export PATH=$PATH:$JAVA_HOME/bin EOF
root@dlp:~#
root@dlp:~# source /etc/profile.d/java.sh
java --version openjdk 17.0.4 2022-07-19 OpenJDK Runtime Environment (build 17.0.4+8-Ubuntu-122.04) OpenJDK 64-Bit Server VM (build 17.0.4+8-Ubuntu-122.04, mixed mode, sharing) # परीक्षण कार्यक्रम बनाने के लिए सत्यापित करें
root@dlp:~# cat > java_test.java <<'EOF'
class java_test {
public static void main(String[] args) {
System.out.println("Hello Java World !");
}
}
EOF
root@dlp:~# javac java_test.java root@dlp:~# java java_test Hello Java World ! |
[2] | यदि आपने आधिकारिक रिपॉजिटरी से Java के एकाधिक संस्करण स्थापित किए हैं, तो उन्हें [update-alternatives] के साथ स्विच करना संभव है। |
root@dlp:~# update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-17-openjdk-amd64/bin/java 1711 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
2 /usr/lib/jvm/java-17-openjdk-amd64/bin/java 1711 manual mode
3 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number: 0
root@dlp:~# update-alternatives --config javac
There are 3 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-17-openjdk-amd64/bin/javac 1711 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/javac 1111 manual mode
2 /usr/lib/jvm/java-17-openjdk-amd64/bin/javac 1711 manual mode
3 /usr/lib/jvm/java-8-openjdk-amd64/bin/javac 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number: 0
root@dlp:~# java -version openjdk version "17.0.4" 2022-07-19 OpenJDK Runtime Environment (build 17.0.4+8-Ubuntu-122.04) OpenJDK 64-Bit Server VM (build 17.0.4+8-Ubuntu-122.04, mixed mode, sharing)root@dlp:~# javac -version javac 17.0.4 |
Sponsored Link |