转载

openjdk还是官方jdk

这几天要下线老的ELK集群,本想着从系统中删除软件就可以了,可发现logstash使用的JDK还是原有ELK版本集成的JDK,所以整理了下。

  • 使用JDK还是JRE?

  • 使用官方JDK还是OpenJDK?

  • 是使用软件(比如ELK、Kafka)集成的JDK,还是独立的JDK?

Elasticsearch 如何引用JDK(reference/current/setup.html)?

Elasticsearch is built using Java, and includes a bundled version of OpenJDK from the JDK maintainers (GPLv2+CE) within each distribution. The bundled JVM is the recommended JVM and is located within the jdk directory of the Elasticsearch home directory. To use your own version of Java, set the JAVA_HOME environment variable. If you must use a version of Java that is different from the bundled JVM, we recommend using a supported LTS version of Java

OpenJDK是Java SE平台版的开源和免费实现,所以Java JDK和OpenJDK可以等同,JDK包含JRE。

OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java Platform, Standard Edition (Java SE). OpenJDK is the official reference implementation of Java SE since version 7.

考虑到统一,建议 单独安装JDK ,然后通过JAVA_HOME引用,这样也方便升级。

如何安装呢?

软件地址:

  • OpenJDK:

    https://jdk.java.net/java-se-ri/13

  • 官方JDK:

    https://www.oracle.com/java/technologies/javase-downloads.html

安装方法:

curl -O https://download.java.net/java/GA/jdk12.0.1/69cfe15208a647278a19ef0990eea691/12/GPL/openjdk-12.0.1_linux-x64_bin.tar.gz
tar xvf openjdk-12.0.1_linux-x64_bin.tar.gz
mv jdk-12.0.1 /usr/local/openjdk12

cat <<EOF | sudo tee /etc/profile.d/jdk12.sh
export JAVA_HOME=/usr/local/openjdk12
export PATH=/$PATH:/$JAVA_HOME/bin
EOF

source /etc/profile.d/jdk12.sh
java  --version
whereis java
echo $JAVA_HOME

如果PATH有原来JDK路径也没有关系,重新打开一个窗口,失效的旧JDK路径会自动消失。

另外也可以使用下面命令切换不同版本的Java:

alternatives --config java

现在Java还是主流,可惜自己这辈子也不会去学了。

原文  http://mp.weixin.qq.com/s?__biz=MzAwOTU4NzM5Ng==&mid=2455771326&idx=1&sn=e093e6a7ba50c3d1795d316fca74f4e5
正文到此结束
Loading...