简体   繁体   中英

Project migration from Java 6 to OpenJDK8

The project I work on (at work) is written in Java and using Java 6. We are trying to migrate to OpenJDK8. We must use Eclipse Indigo for it (it's part of the project). After reading some of the previous threads I followed the steps of how to migrate. The steps I followed:

  1. Going to Windows -> Preferences -> Java -> Installed JRE's . There I clicked add and choose the path to an installed version 1.8.0 of Java.
  2. Then I went to Project -> Properties -> Java Build Path -> Libraries . There I choose JRE System Library and clicked edit . In Alternate JRE I choose 1.8.0 .
  3. Then I went to Build -> External tools configuration -> JRE . In the Separate JRE section I choose 1.8.0 .

Then I got an error (not compiled or run time error - just eclipse shows with red mark) in a Java file which was opened: (The error occurred after the second step)

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

Part of the code:

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

It says the error because of arg.contains("~~") . I have read all the previous threads about that error but they suggest to go back to the old Java version (Although we would like to move to OpenJDK8). I tried to build and it actually does not has any compilation errors. I'm not sure if I should be happy or sad about it, because I'm not sure if I actually built it properly with OpenJDK8 . To sum it up I'll try to ask some direct questions:

  1. How can I verify that I build it with the right version?
  2. How should I make sure that all of the features are working as they were with Java 6 ?
  3. How to fix that Eclipse red mark error that I pointed out?

EDIT : I clicked restart to restart the Eclipse and now when I try to build it, it fails. The first part of the log file looks as follows:

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

I guess some of the featuers are failing. I know that Sun class has changed in version 8. Maybe it's the reason?

EDIT2: From previous threads I have learned that Eclipse Indiago does not work well with Java 8. So I moved to Luna. But most of the files now fail because my project uses Indiago. Some of the errors:

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

How to solve those errors?

EDIT3: As I understand, Indigo does not supports Java 8. So I moved to Luna. But now every plugin fails. There are a bunch of paths that does not exists in Windows -> Preferences -> Plug-in Development -> Target Platform -> Running Platform -> edit . The project uses Indigo and not Luna so the paths does not exists:

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

It became a long thread and I'm sorry for that. How to solve it?

From your comment you state you are using Indigo. Java 8 support wasn't introduced until Luna, although Kepler could support it with a patch. https://www.eclipse.org/lists/eclipse.org-committers/msg00948.html

Although here is a blog of someone who got it to work with Juno: https://tuhrig.de/java-8-in-eclipse-juno/

Here's a stack overflow answer that says they couldn't get it to work with Indigo. https://stackoverflow.com/a/40053177/3501286

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM