0

I am pretty new to Java and Eclipse.

Today I was working on Eclipse, and after starting a switch statement, there was a red underline under the word "text" here - switch (text){

I clicked on the red x on the left where it explains what the problem is, and it was saying something like this (paraphrasing): "change it to java 1.7 to fix this problem".

After doing that, I got red axes all over my code. I want to undo this but don't know how.

I noticed there is a red exclamation point on the name of my project in the package explorer. I tried to right click on my project, properties, Java compiler, then unchecked the box saying "Use compliance from execution environment 'Java SE- 1.7 on the "Java Build Path'

I believe I was running on 1.6.

This did not fix the problem.

Please help!

1 Answers1

0

The original error was most likely caused by trying to switch on a String variable. You cannot do this in Java 1.6 as this functionality was only introduced in Java 1.7.

If you uncheck the box 'Use compliance from execution environment', you should be able to set the compiler compliance level directly in the dropdown immediately under the greyed-out box (on the right of that line). Having said that, be aware Oracle stopped providing public updates to Java 1.6 in February 2013 - just over eighteen months ago - and public updates for 1.7 are slated to cease in April 2015. Unless you are really pushed for time or are stuck authoring for a legacy environment, now might be a good time to consider upgrading to Java 1.8 so you can take advantage of the new language features. The error marks that appear when you upgrade usually indicate obsolete programming practices.

With regard to the red exclamation mark on your project name, this is usually caused by a build path problem. Have a look at Project->Properties->Java Build Path->Libraries for the cause.

Flic
  • 751
  • 8
  • 19