Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Java11 (Java10) with Eclipse Plugin?

If I specify JavaSE-10 as minimum execution environment in my Eclipse plugin:

enter image description here

I get following errors when starting my plugin as Eclipse Application:

enter image description here

org.osgi.framework.BundleException: Could not resolve module: org.treez.core [597]
  Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=10))"
  Unresolved requirement: Require-Bundle: org.treez.javafxd3; visibility:="reexport"
    -> Bundle-SymbolicName: org.treez.javafxd3; bundle-version="1.0.0.qualifier"; singleton:="true"
       org.treez.javafxd3 [586]
         Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=10))"

    at org.eclipse.osgi.container.Module.start(Module.java:444)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1634)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1613)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1585)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1528)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

I checked that

  • Java10 is reverenced under Installed JREs
  • 10 is selected as compliance level

I use Oxygen.3a Release (4.7.3a) Build id: 20180405-1200

=>Is this a bug in eclipse equinox?

=>What else can I check to resolve this issue?

enter image description here

If I remove JavaSE-10 from the minimum execution environment settings I am able to start the Eclipse Application and the plugin seems to work fine.

When I export the plugin I get following warning:

# 25.04.18, 12:25:40 MESZ
# Eclipse Compiler for Java(TM) v20180330-0919, 3.13.102, Copyright IBM Corp 2000, 2015. All rights reserved.
option -bootclasspath not supported at compliance level 9 and above

When I try to use the plugin after installing it from my update page, I get a ClassNotFoundException:

...
Caused by: java.lang.ClassNotFoundException: org.treez.views.tree.TreeViewPart cannot be found by org.treez.views_1.0.0.201804191641
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:484)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.loadClass(EquinoxBundle.java:564)
    at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:174)
    ... 114 more

If I use Java8 everything works fine.

Related questions:

  • Java 8 & Missing required capability Require-Capability: osgi.ee; filter="(&(osgi.ee=JavaSE)(version=1.8))"

  • How to set up java 10 in Eclipse Oxygen?

  • How to add org.eclipse.swt (and other plugin dependencies) as an automatic Java9 module?

like image 626
Stefan Avatar asked Apr 25 '18 10:04

Stefan


People also ask

How do I enable Java 11 in Eclipse?

A Java 11 JRE is recognized by Eclipse for launching. It can be added from the Window > Preferences > Java > Installed JREs > Add... page. It can also be added from the Package Explorer using the project's context menu.

What version of Eclipse works with Java 11?

Eclipse 4.23 (2022-03) It is the supported release. A Java 11 or newer JRE/JDK is required, LTS release are preferred to run all Eclipse 2022-03 packages based on Eclipse 4.23, with certain packages choosing to provide one by default.


1 Answers

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.
like image 86
ZhekaKozlov Avatar answered Oct 16 '22 13:10

ZhekaKozlov