How to use Java11 (Java10) with Eclipse Plugin?

南笙酒味 提交于 2019-11-30 14:16:15

It looks like Eclipse OSGi does not support Java SE 10 yet. I downloaded the latest Eclipse Oxygen 4.7.3a and opened plugins/org.eclipse.osgi_3.12.100.v20180210-1608.jar. The last supported profile was JavaSE-9.

So, you have two choices here:

  • Wait until OSGi officially supports JavaSE-10 profile.
  • If you really want to write a plugin with Java 10 and you have control over the plugins folder (e.g. you develop an Eclipse RCP application), open the OSGI jar and add a new profile JavaSE-10. To do this, you can copy JavaSE-9.profile to JavaSE-10.profile and fix corresponding lines in the new file. Also, you must add a new line to profile.list.

Since OSGi 4.3, the most appropriate way to specify a minimum Java version is using the Required-Capability header, as in:

Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version>=1.10))"

I have had success fixing the reported error by replacing all occurrences of Bundle-RequiredExecutionEnvironment with the above line. In PDE, you may get a warning on the manifest file, but it can be safely ignored. Product validation and product exports seems to work without issue.

The semantic of the BREE header required that an execution environnement descriptor be provided by the OSGi implementation for each specific release of the JRE. In Equinox, this used to be defined through ".profile" files; these profiles have been supported by Equinox up to JavaSE-9, but it has been announced that Equinox they would no longer provide profiles for newer releases of Java.

The Tycho community has handled this issue on their side by creating their own Java 10 profile, but it can't be used directly from PDE. The P2 community is considering copying Tycho's Java 10 profile, but this has been stalled for a long time. I'm not sure how P2 reacts at present when fed bundles that do not contains the BREE header.

What worked for me as a work around was to

  • Remove the required version entries from the manifest files and ignore the corresponding warnings

  • Activate the option "Use class files compiled in the workspace" in the export wizard:

(Therefore I assume that something goes wrong during the compilation step of the export wizard if that option is not applied.)

I used Java 11.0.1 and Eclipse SimRel 2018-09 (plus Java11 support plugin)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!