Eclipse氧气+ Java 9 [英] Eclipse Oxygen + Java 9
问题描述
为了测试项目是否已为Java 9准备就绪,我尝试了最后几个小时来使Eclipse编译整个项目.
这是我所做的:
我正在虚拟机中使用 XUbuntu ...
我安装了最新的openjdk-9-*
软件包,并删除了所有Java 8软件包.
我下载了eclipse oxygen的eclipse安装程序,并安装了Java SE的eclipse的默认版本.
我开始eclipse并安装了 Java 9支持包从市场上尝试导入gradle项目.
一切到此为止一切都很好. (软件包和eclipse遇到了一些问题,但引发了一些错误消息,但总的来说还是有效的.
项目已成功导入,但出现以下错误消息:
The project was not built since its build path is incomplete. Cannot
find the class file for java.lang.Object. Fix the build path then try
building this project
The type java.lang.Object cannot be resolved. It is indirectly
referenced from required .class files
当尝试刷新工作空间时,出现以下错误消息:
Errors occurred during the build.
Errors running builder 'Java Builder' on project '<projectName>'.
java.lang.NullPointerException
标准输出充满了FileNotFoundExceptions
,就像这样:
java.io.IOException: /usr/lib/jvm/jrt-fs.jar not exist
at jdk.internal.jrtfs.JrtFileSystemProvider.newFileSystem(java.base@9-internal/JrtFileSystemProvider.java:122)
at jdk.internal.jrtfs.JrtFileSystemProvider.newFileSystem(java.base@9-internal/JrtFileSystemProvider.java:108)
at java.nio.file.FileSystems.newFileSystem(java.base@9-internal/FileSystems.java:342)
at java.nio.file.FileSystems.newFileSystem(java.base@9-internal/FileSystems.java:291)
at org.eclipse.jdt.internal.compiler.util.JrtFileSystem.initialize(JRTUtil.java:204)
at org.eclipse.jdt.internal.compiler.util.JrtFileSystem.<init>(JRTUtil.java:181)
at org.eclipse.jdt.internal.compiler.util.JRTUtil.getJrtSystem(JRTUtil.java:118)
at org.eclipse.jdt.internal.compiler.util.JRTUtil.walkModuleImage(JRTUtil.java:147)
at org.eclipse.jdt.internal.core.JavaProject.loadModulesInJimage(JavaProject.java:727)
at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:647)
at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:805)
at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:769)
at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:577)
at org.eclipse.jdt.internal.core.ClasspathChange.generateDelta(ClasspathChange.java:401)
at org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged(DeltaProcessor.java:2096)
at org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(DeltaProcessingState.java:473)
at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:299)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:289)
at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:152)
at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:374)
at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1469)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2253)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5624)
at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:105)
at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter$1.run(WorkbenchRunnableAdapter.java:118)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
这并不令人惊讶,因为JDK(和相应的文件)位于usr/lib/jvm/java-9-openjdk-amd64
.
为了解决此问题,我创建了一个从/usr/lib/jvm/jrt-fs.jar
指向/usr/lib/jvm/java-9-openjdk-amd64/jrt-fs.jar
的符号链接,该链接消除了这些错误,但是在Eclipse中搜索了也不存在的/usr/lib/jvm/modules
...
>
忽略以下部分:
我尝试将--add-modules=java.se.ee
(如Java 9支持插件所建议)附加到启动参数并添加了它,这对eclipse.ini文件的末尾没有任何作用,导致eclipse不再启动.
我的eclipse.ini
文件:
-startup
plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
--launcher.library
../../../.p2/pool/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.500.v20161213-1756
-product
org.eclipse.epp.package.java.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
/usr/lib/jvm/java-9-openjdk-amd64/bin/ #Changing this to /usr/<folders>/bin/java changed nothing
-install
/home/robin/eclipse/java-oxygen/eclipse
-vmargs
-Dosgi.requiredJavaVersion=1.8
-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=java.se.ee
#Appending this command line argument here causes eclipse to not start - "Could not create JVM"
#This argument can of course also be passed via the command line directly
#But this changes nothing
我遇到了同样的问题. Eclipse在JDK根目录中找不到jrt-fs.jar.尝试改为使用Java 9 JRE运行项目.完整的分步解决方案描述了此处
In order to test if a project is ready for java 9, I tried the last couple hours to get eclipse compiling the complete project.
Here's what I did:
I'm using XUbuntu in a virtual machine by the way...
I installed the latest openjdk-9-*
packages and removed all java 8 packages.
I downloaded the eclipse installer for eclipse oxygen and installed the default version of eclipse for Java SE.
I started eclipse and installed the Java 9 Support Package from the marketplace and tried importing the gradle project.
Everything went more or less fine until this point. (Had a couple problems with the packages and eclipse threw some error messages but all in all it worked.)
The project was successfully imported,but I get this error messages:
The project was not built since its build path is incomplete. Cannot
find the class file for java.lang.Object. Fix the build path then try
building this project
The type java.lang.Object cannot be resolved. It is indirectly
referenced from required .class files
When it's trying to refresh the workspace, I get the following error Message:
Errors occurred during the build.
Errors running builder 'Java Builder' on project '<projectName>'.
java.lang.NullPointerException
The standard output is full of FileNotFoundExceptions
like this one:
java.io.IOException: /usr/lib/jvm/jrt-fs.jar not exist
at jdk.internal.jrtfs.JrtFileSystemProvider.newFileSystem(java.base@9-internal/JrtFileSystemProvider.java:122)
at jdk.internal.jrtfs.JrtFileSystemProvider.newFileSystem(java.base@9-internal/JrtFileSystemProvider.java:108)
at java.nio.file.FileSystems.newFileSystem(java.base@9-internal/FileSystems.java:342)
at java.nio.file.FileSystems.newFileSystem(java.base@9-internal/FileSystems.java:291)
at org.eclipse.jdt.internal.compiler.util.JrtFileSystem.initialize(JRTUtil.java:204)
at org.eclipse.jdt.internal.compiler.util.JrtFileSystem.<init>(JRTUtil.java:181)
at org.eclipse.jdt.internal.compiler.util.JRTUtil.getJrtSystem(JRTUtil.java:118)
at org.eclipse.jdt.internal.compiler.util.JRTUtil.walkModuleImage(JRTUtil.java:147)
at org.eclipse.jdt.internal.core.JavaProject.loadModulesInJimage(JavaProject.java:727)
at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:647)
at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:805)
at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:769)
at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:577)
at org.eclipse.jdt.internal.core.ClasspathChange.generateDelta(ClasspathChange.java:401)
at org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged(DeltaProcessor.java:2096)
at org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(DeltaProcessingState.java:473)
at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:299)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:289)
at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:152)
at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:374)
at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1469)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2253)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5624)
at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:105)
at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter$1.run(WorkbenchRunnableAdapter.java:118)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
Which isn't suprising, since the JDK (and the respective file) is located at usr/lib/jvm/java-9-openjdk-amd64
.
In order to fix this issue, I created a symlink pointing from /usr/lib/jvm/jrt-fs.jar
to /usr/lib/jvm/java-9-openjdk-amd64/jrt-fs.jar
, which got rid of those errors, but eclipse searched for /usr/lib/jvm/modules
which isn't existing as well...
Ignore the following part:
I tried appending --add-modules=java.se.ee
(as suggested by the java 9 support plugin) to the launch arguments and added it, after this did nothing to the end of the eclipse.ini file which caused eclipse to no longer launch.
My eclipse.ini
File:
-startup
plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
--launcher.library
../../../.p2/pool/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.500.v20161213-1756
-product
org.eclipse.epp.package.java.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
/usr/lib/jvm/java-9-openjdk-amd64/bin/ #Changing this to /usr/<folders>/bin/java changed nothing
-install
/home/robin/eclipse/java-oxygen/eclipse
-vmargs
-Dosgi.requiredJavaVersion=1.8
-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=java.se.ee
#Appending this command line argument here causes eclipse to not start - "Could not create JVM"
#This argument can of course also be passed via the command line directly
#But this changes nothing
I had the same issue. Eclipse can not find jrt-fs.jar in JDK root directory. Try running your project with Java 9 JRE instead. Complete step by step solution described here
这篇关于Eclipse氧气+ Java 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!