簡體   English   中英

項目從Java 6遷移到OpenJDK8

[英]Project migration from Java 6 to OpenJDK8

我工作的項目(在工作中)是用Java編寫的,並使用Java 6.我們正在嘗試遷移到OpenJDK8。 我們必須使用Eclipse Indigo(它是項目的一部分)。 在閱讀了一些以前的線程后,我遵循了如何遷移的步驟。 我遵循的步驟:

  1. 轉到Windows -> Preferences -> Java -> Installed JRE's 在那里我點擊add並選擇已安裝的1.8.0 Java的路徑。
  2. 然后我去了Project -> Properties -> Java Build Path -> Libraries 在那里,我選擇JRE System Library並單擊edit Alternate JRE我選擇1.8.0
  3. 然后我去了Build -> External tools configuration -> JRE Separate JRE部分中,我選擇1.8.0

然后我在打開的Java文件中收到錯誤(未編譯或運行時錯誤 - 只是帶有紅色標記的eclipse顯示):(第二步后發生錯誤)

The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files

部分代碼:

final String arg = getOption(ArgNames.JOB);
if (arg.contains("~~")) {
    return arg.split("~~")[1];
} else {
    return arg;
}

它說錯誤是因為arg.contains("~~") 我已經閱讀了有關該錯誤的所有先前的線程,但他們建議回到舊的Java版本(雖然我們想轉向OpenJDK8)。 我試圖構建它實際上沒有任何編譯錯誤。 我不確定我是否應該高興或悲傷,因為我不確定我是否真的使用OpenJDK8正確構建它。 總結一下,我會試着提出一些直接的問題:

  1. 如何驗證我是否使用正確的版本構建它?
  2. 我應該如何確保所有功能都像Java 6
  3. 如何解決我指出的Eclipse紅色標記錯誤?

編輯 :我點擊restart重啟Eclipse,現在當我嘗試構建它時,它失敗了。 日志文件的第一部分如下所示:

!SESSION 2019-04-18 18:45:36.356 -----------------------------------------------
eclipse.buildId=M20120208-0800
java.version=1.8.0
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  -application org.eclipse.ant.core.antRunner -buildfile tools/eclipse3.7.1-x86_64/plugins/org.eclipse.build_3.7.0.v20111116-2009//scripts/productBuild/productBuild.xml -Dtimestamp=2010
Command-line arguments:  -application org.eclipse.ant.core.antRunner -buildfile tools/eclipse3.7.1-x86_64/plugins/org.eclipse.build_3.7.0.v20111116-2009//scripts/productBuild/productBuild.xml -Dtimestamp=2010

!ENTRY org.eclipse.osgi 4 0 2019-04-18 18:45:53.567
!MESSAGE Application error
!STACK 1
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.ant.core.AntRunner.run(AntRunner.java:513)
    at org.eclipse.ant.core.AntRunner.start(AntRunner.java:600)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: tools/eclipse3.7.1-x86_64/plugins/org.eclipse.build_3.7.0.v20111116-2009/scripts/productBuild/productBuild.xml:43: The following error occurred while executing this line:
tools/eclipse3.7.1-x86_64/plugins/org.eclipse.build_3.7.0.v20111116-2009/scripts/build.xml:105: The following error occurred while executing this line:
tools/eclipse3.7.1-x86_64/plugins/org.eclipse.build_3.7.0.v20111116-2009/templates/headless-build/customTargets.xml:12: The following error occurred while executing this line:
tools/eclipse3.7.1-x86_64/plugins/org.eclipse.build_3.7.0.v20111116-2009/scripts/productBuild/allElements.xml:20: The following error occurred while executing this line:
tools/eclipse3.7.1-x86_64/plugins/org.eclipse.build_3.7.0.v20111116-2009/scripts/genericTargets.xml:118: The following error occurred while executing this line:
tools/eclipse3.7.1-x86_64/plugins/org.eclipse.build_3.7.0.v20111116-2009/scripts/genericTargets.xml:123: The following error occurred while executing this line:
tools/workspace/buildFiles/features/org.eclipse.build.container.feature/build.xml:30: The following error occurred while executing this line:
tools/workspace/buildFiles/features/org.eclipse.build.container.feature/build.xml:16: The following error occurred while executing this line:
tools/workspace/buildFiles/features/com.feature/build.xml:278: The following error occurred while executing this line:
tools/workspace/buildFiles/features/com.feature/build.xml:109: The following error occurred while executing this line:
tools/workspace/buildFiles/plugins/com.testmanagement/build.xml:235: The following error occurred while executing this line:
tools/workspace/buildFiles/plugins/com.testmanagement/build.xml:196: Compile failed; see the compiler error output for details.

我猜有些功能失敗了。 我知道Sun類在版本8中已經改變了。也許是因為這個原因?

編輯2:從之前的主題我已經了解到Eclipse Indiago與Java 8不兼容。所以我轉向了Luna。 但是大多數文件現在都失敗了,因為我的項目使用了Indiago。 一些錯誤:

The import org.eclipse cannot be resolved
The import org.osgi cannot be resolved
The import junit cannot be resolved

如何解決這些錯誤?

編輯3:據我所知,Indigo不支持Java 8.所以我轉向了Luna。 但現在每個插件都失敗了。 Windows -> Preferences -> Plug-in Development -> Target Platform -> Running Platform -> edit中沒有一堆路徑Windows -> Preferences -> Plug-in Development -> Target Platform -> Running Platform -> edit 該項目使用Indigo而不是Luna,因此路徑不存在:

./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.eclipse.ui.presentations.r21.source_3.2.200.I20100517-1500.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.eclipse.ui.source_3.7.0.v20110928-1505.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.eclipse.ui.views.log.source_1.0.200.v20110404.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.eclipse.ui.views.properties.tabbed.source_3.5.200.v20110928-1505.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.eclipse.ui.views.source_3.6.0.v20110928-1505.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.eclipse.ui.workbench.compatibility.source_3.2.100.I20110413-1600.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.eclipse.ui.workbench.source_3.7.1.v20120104-1859.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.eclipse.ui.workbench.texteditor.source_3.7.0.v20110928-1504.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.eclipse.update.configurator.source_3.3.100.v20100512.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.eclipse.update.core.source_3.2.500.v20110330.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.eclipse.update.scheduler.source_3.2.300.v20100512.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.eclipse.update.ui.source_3.2.300.v20100512.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.hamcrest.core.source_1.1.0.v20090501071000.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.hamcrest.integration.source_1.1.0.v20090501071000.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.hamcrest.library.source_1.1.0.v20090501071000.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.hamcrest.text.source_1.1.0.v20090501071000.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.junit.source_3.8.2.v3_8_2_v20100427-1100.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.junit.source_4.8.2.v4_8_2_v20110321-1705.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.mortbay.jetty.server.source_6.1.23.v201012071420.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.mortbay.jetty.util.source_6.1.23.v201012071420.jar
./.metadata/.log:!MESSAGE File does not exist: tools/eclipse/4.4/plugins/org.objectweb.asm.source_3.3.1.v201105211655.jar

它成了一個很長的線程,我很抱歉。 怎么解決?

根據您的評論,您聲明您正在使用Indigo。 直到Luna才引入Java 8支持,盡管Kepler可以通過補丁來支持它。 https://www.eclipse.org/lists/eclipse.org-committers/msg00948.html

雖然這里有一個博客,有人將其與Juno合作: https//tuhrig.de/java-8-in-eclipse-juno/

這是一個堆棧溢出的答案,說他們無法讓它與Indigo一起工作。 https://stackoverflow.com/a/40053177/3501286

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM