java和氧气燃烧方程式,Eclipse氧气+ Java 9

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 ''.

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.(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//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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值