What to do if you get a NoClassDefFoundError when trying to run eclipse on Java9

I replaced the HDD of the desktop with SSD, so I was building the environment. Java 9 was officially released, and when I tried to create an environment with Java 9 + eclipse 4.7, it broke at startup.

2017/12/5 postscript:

https://wiki.eclipse.org/Configure_Eclipse_for_Java_9

Users who install Eclipse Oxygen 4.7.1a are able to launch with Java 9 and get Java 9 support, and the configuration described below won't be necessary anymore. There might be cases which won't work, see item 3 below in that case.

So let's install eclipse 4.7.1a or later

2017/09/27 postscript:

https://wiki.eclipse.org/Configure_Eclipse_for_Java_9 It was written to add --add-modules = ALL-SYSTEM to. (2017/10/02) It worked without any problem, so I fixed it.

TL;DR Add --add-modules = ALL-SYSTEM to -vmargs in eclipse.ini.

eclipse.ini


-vmargs
--add-modules=ALL-SYSTEM

environment

OS: Windows8.1 64bit JDK: Java SE Development Kit 9 eclipse: Oxygen Release (4.7.0)

What i did

JDK installation

-> Leave default

> java -version
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

eclipse installation

-> Set jdk path with -vm in eclipse.ini

eclipse.ini


-vm
C:\Program Files\Java\jdk-9\bin\javaw.exe

Create a workspace and start it

-> I got an error

.log


!SESSION 2017-09-24 20:47:30.135 -----------------------------------------------
eclipse.buildId=4.7.0.I20170612-0950
java.version=9
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=ja_JP
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

!ENTRY org.eclipse.osgi 4 0 2017-09-24 20:47:33.101
!MESSAGE Application error
!STACK 1
org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:410)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:318)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)

...Abbreviation...

Caused by: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
	at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:124)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:399)
	... 23 more
Caused by: java.lang.ClassNotFoundException: javax.annotation.PostConstruct cannot be found by org.eclipse.e4.core.di_1.6.100.v20170421-1418
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:433)
	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:496)
	... 25 more

!ENTRY org.eclipse.e4.ui.workbench 4 0 2017-09-24 20:47:33.117
!MESSAGE FrameworkEvent ERROR
!STACK 0
java.lang.NoClassDefFoundError: javax/annotation/PreDestroy
	at org.eclipse.e4.core.internal.di.InjectorImpl.disposed(InjectorImpl.java:450)
	at org.eclipse.e4.core.internal.di.Requestor.disposed(Requestor.java:156)
	at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:78)
	at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:111)
	at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.handleInvalid(TrackableComputationExt.java:74)
	at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:178)

...Abbreviation...

Caused by: java.lang.ClassNotFoundException: javax.annotation.PreDestroy cannot be found by org.eclipse.e4.core.di_1.6.100.v20170421-1418
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:433)
	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:496)
	... 21 more

Added --add-modules = ALL-SYSTEM to -vmargs in eclipse.ini

eclipse.ini


    -vmargs
    -Dosgi.requiredJavaVersion=1.8
    [email protected]/eclipse-workspace
    -XX:+UseG1GC
    -XX:+UseStringDeduplication
    -Dosgi.requiredJavaVersion=1.8
    -Xms256m
    -Xmx1024m
    -Declipse.p2.max.threads=10
    -Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest
    -Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/
+   --add-modules=ALL-SYSTEM

-> You started it

reference

https://wiki.eclipse.org/Configure_Eclipse_for_Java_9 https://www.eclipse.org/eclipse/news/4.6/platform.php#java-9 https://issues.jboss.org/browse/JBIDE-22417?focusedCommentId=13310535&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel&_sscc=t#comment-13310535

Recommended Posts

What to do if you get a NoClassDefFoundError when trying to run eclipse on Java9
What to do if you get a JNI shared library error when trying to build in Eclipse
What to do if you get a port error when docker-compose up on Mac
What to do if you get a MiniMagick vulnerability alert on GitHub
What to do if you get a java.io.IOException in GlassFish
What to do if you get a gcc error in Docker
What to do if you get a DISPLAY error in gym.render ()
What to do when you run into a docker-compose node_modules problem
What to do if you get a "Cannot Pull Container Error" when starting ECS ​​Fargate
What to do if you get an error when you hit Heroku logs
What to do if you accidentally create a model
What to do if you get a SQLite3 :: BusyException: database is locked error
What to do if you have installed Java for OS X on macOS
What to do if you get an error on heroku rake db: migrate
What to do if you get To install the missing version, run `gem install bundler: 2.1.4`
What to do if you get a wrong number of arguments error in binding.pry
What to do if you get an "A server is already running." Error when you try to start the rails server
What to do if you get Could not save master table to file after importing a project in Eclipse
[Rails] What to do if you get an error saying "Could not find a JavaScript runtime." When executing the rails s command on Catalina
[Java] What to do if you get an error in Eclipse saying "Not allowed at source level below 1.X"
What to do if you get an error saying "Please enter a valid value" when getting with Rails datetime_field
What to do if you get an error saying "Could not find a JavaScript runtime." When starting rails server
What to do if a SAX Parser error occurs when using Liferay 7 / DXP on AWS
What to do if you get a "302" error in your controller unit test code in Rails
What to do if you get angry with OpenSSL with pyenv install
What to do when you become a Problem During Content Assist
[Rails] What to do if you can't get parameters with form_with
What to do when a javax.el.PropertyNotWritableException occurs
What to do if you install Ubuntu
What to do if you select a JRE in Eclipse and get "The selected JRE does not support the current compliance level 11"
What to do if you go offline due to SSL certificate error when running Jenkins on Mac
What to do if you get a "Mysql2 :: Error: Operand should contain 1 column (s)" error in Rails
What to do if you get "Changes not staged for commit:" when you git status after git add.
What to do if you get an error during rails db: reset
What to do if you get an uninitialized constant Likes Controller error
What to do if you can't install the plugin from the Eclipse marketplace
What to do if tomcat process remains when tomcat is stopped in eclipse
What to do when "call'Hoge.connection' to establish a connection" appears on rails c
Notes on what to do when a WebView ClassNotFoundException occurs in JavaFX 12
What to do if you push incorrect information
What do you use when converting to String?
What to do if you get Application with name appName is already registered. When you try to start GlassFish
The first thing to do when you want to be happy with Heroku on GitHub with Eclipse in Java
What to do if Operation not permitted is displayed when you execute a command in the terminal
What to do if you get the error Too long with no output (exceeded 10m0s) on CircleCI
What to do when you want to delete a migration file that is "NO FILE"
What to do when you think you can't do Groovy-> Java in IntelliJ IDEA CE
What to do if you get Could not locate Gemfile or .bundle / directory
What to do if you get the error message unrecognized selector send to instance "***"
What to do if you get angry if you don't have nokogiri while installing wp2txt
What to do if the rails server doesn't run out on AWS cloud9
What to do if you get a javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake in the IBM JDK
What to do if ClassNotFoundException occurs when starting Tomcat
What to do if TextToSpeech doesn't work on Android 11
What to do when a null byte error occurs
What to do when rails creates a 〇〇 2.rb file
How to run Java EE Tutial on github on Eclipse
What to do if you can't get the text of an element in Selenium
What to do if you get the error Couldn't find Item without an ID
What to do if you cannot execute with the command "Java package name / class name"
[Solution] What to do if you get a Docker error'ERROR: Cannot connect to the Docker daemon at unix: ///var/run/docker.sock. Is the docker daemon running?'