从 openJDK 8 升级到 openJDK 11

huangapple go评论58阅读模式
英文:

Upgrading from openJDK 8 to openJDK 11

问题

我在我的Ubuntu 18.04系统中安装了JDK 8,现在我想使用此链接将其升级到JDK 11。我只想知道这样做是否会导致任何问题。在升级时,旧版本会被移除吗(实际上我希望旧版本能自行移除)?

英文:

I have JDK 8 installed in my ubuntu 18.04 system and I now want to upgrade it to JDK 11 using this. I just want to know if this would create any problem or not. Would the older version be removed on upgrading( Actually I want older version to be removed by itself)?

答案1

得分: 6

以下是翻译好的内容:

执行以下步骤,在Ubuntu上卸载先前的openJDK版本:

sudo apt-get remove openjdk

要删除所有配置文件和依赖项,请运行:

sudo apt-get purge --auto-remove openjdk*

然后安装openJDK 11:

sudo apt-get install openjdk-11-jdk
英文:

Do this to uninstall previous versions of openJDK on Ubuntu

sudo apt-get remove openjdk

To remove all of the config files and dependencies.

sudo apt-get purge --auto-remove openjdk*

Then install openJDK 11

sudo apt-get install openjdk-11-jdk

答案2

得分: 1

升级通常允许适用于Java 8编译的代码运行;但是,有一些注意事项。

包含了Project Jigsaw项目意味着达到方法的访问规则略有变化。在Java 8和Java 11之间几乎是兼容的。差异将在以下情况下显现:

  1. 尝试使用com.sun.*包(或任何其他非公共API入口点)。
  2. 尝试对非公共API入口点使用反射。
  3. 修改启动以使用模块,这将停用Java 8的“默认”模块处理。

简而言之,这几乎是一个简单的升级。问题出现在代码正在执行不应该执行的操作时,或者当您的代码未经过模块化设计,而您的某些运行时代码是为模块设计的。

如果您可以访问源代码,可以通过添加模块规范来修复许多问题;但是,这可能需要您理解模块化(这相当简单,但仍然是一个障碍)。

英文:

An upgrade will generally allow code compiled for Java 8 to run; but, there are some caveats.

The inclusion of Project JigSaw means that the access rules for "reaching" a method have changed slightly. They are almost compatible between Java 8 and Java 11. The differences will show when:

  1. You try to use one of the com.sun.* packages (or any other non-public api entry point).
  2. You try to use reflection on a non-public API entry point.
  3. You alter the launch to use a module, which will deactivate the Java 8 "default" module handling.

In short, it's almost an easy upgrade. The problems come into play when code is doing something it shouldn't have done, or when you have code not designed for modules, and some of your runtime code is designed for modules.

If you have access to source code, you can fix a lot of this by adding in the module specifications; but, that might require you to understand modularity (which is pretty easy, but a barrier nonetheless).

huangapple
  • 本文由 发表于 2020年9月2日 13:25:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/63699194.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定