4

I recently updated to using Java 8 on my computer for eclipse. I had previously been using Java 7. At first the update seemed to work fine as I could compile and run a simple hello world-program. However, as I began to import previous projects that I had been working on that used the class java.util.Arrays, I got an error like Arrays could not be resolved. I have been having a similar problem with the PriorityQueue class saying that,

The type java.util.Comparator cannot be resolved. It is indirectly referenced from required .class files.

12
  • 3
    Can you please post a minimally working example? It sounds like you have a problem with referencing the JDK in your project in Eclipse. Commented Jun 30, 2014 at 12:57
  • 1
    import java.util.Arrays; import java.util.Comparator; Commented Jun 30, 2014 at 12:58
  • Is the new JDK correctly mapped in eclipse? Commented Jun 30, 2014 at 12:58
  • In the import statement it says the import cannot be resolved Commented Jun 30, 2014 at 13:01
  • @popgalop Are you sure that the rt.jar of your JRE is in your classpath? Commented Jun 30, 2014 at 13:03

2 Answers 2

2

I ran into something really similar today. Not sure if its the same issue, but what I did was:

Open project explorer

Right click the project

Find "Configure Build Path" enter image description here

In the window that opens, select the "Libraries" tab enter image description here

Scroll down to JRE System Library (there was a red error symbol next to mine) and click the library.

enter image description here

In the top right, select the Edit button

Choose "Alternate JRE" and then pick (in your case) java 8 enter image description here

Sign up to request clarification or add additional context in comments.

Comments

1

If you import previous Project then the Projects have the JDK for Java 7 in there Buildpath. You only have to update your Buildpathin the Projects to use Java 8. That should solve your problem.

Buildpaths don't will be updated automaticle for every Projects if you update your JDK.

1 Comment

Even when creating a new project it wont work. It only creates a problem for those 2 classes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.