0

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?

vesii
  • 2,760
  • 4
  • 25
  • 71
  • This looks like a valid call to me. I'm using Oracle's Java 8 but that line doesn't give me any errors. Try deleting your imports and having them generated again using ctrl+shift+O. – Bakon Jarser Apr 18 '19 at 15:33
  • You can find the version of java which was used to build by checking MANIFEST file in the jar or by using javap on the .class file: https://fabianlee.org/2018/01/19/java-determining-the-java-version-used-to-compile-a-class-class-file-has-the-wrong-version/ – NeplatnyUdaj Apr 18 '19 at 15:38
  • Are all of your plugins up to date? Have you tried a newer version of eclipse? – Bakon Jarser Apr 18 '19 at 16:36
  • @BakonJarser I just tried Luna because some previous thread has suggested it. But when I opened it, most of the files have failed because the only version I can use is Indigo. So I switched back to Indigo. Also, all of the plugins worked until I switched to `1.8.0`. – vesii Apr 18 '19 at 16:43

1 Answers1

0

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

Bakon Jarser
  • 703
  • 6
  • 20
  • I'd use a newer (even the newest version) of Eclipse. I personally use Oxygen and Neon, both of which work with Java 6+ – Benjamin Urquhart Apr 18 '19 at 17:11
  • So how I make it work with Luna? When I open with Luna, I face some errors. – vesii Apr 18 '19 at 17:56
  • Why do you need luna @vesii? – Benjamin Urquhart Apr 18 '19 at 18:05
  • @BenjaminUrquhart Because BakonJarser said that Indigo does not support Java 8. So I moved to Luna. But every plugin which I used in Indigo now fails. – vesii Apr 18 '19 at 18:11
  • @vesii I would post some details about how you upgraded. Was there an update button in Indigo? Did you do a fresh install? If it wasn't a fresh install then try restarting eclipse and if that doesn't work you may need to uninstall and reinstall your plugins. – Bakon Jarser Apr 18 '19 at 18:28
  • I work on a machine at work. The Java 8 version was already installed and used by others. Also, I specified the steps I made to move to Java 8 within Eclipse. See my third edit. before moving to Java 8, the project used those paths (from indigo Eclipse). Now, it won't work from Luna because these paths do not exist. – vesii Apr 18 '19 at 18:31
  • @Vessi You could try changing those paths on your filesystem from 4.1 to 4.4 but it's probably better to a) make sure your plugins are updated in the marketplace (or whatever they call it in luna) b) if they already are updated then uninstall and reinstall them. – Bakon Jarser Apr 18 '19 at 18:51