Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse source level problems

Tags:

java

eclipse

Eclipse tells me:

for each statements are available only if source level is 1.5 or greater

what does that mean and how do I solve this? I'm trying to import a program I built with NetBeams which has a GUI. Should I post the full code as well?

like image 722
MickG Avatar asked Jan 30 '26 03:01

MickG


2 Answers

Open the Preferences panel and set source level or maybe check Use default compliance settings.

enter image description here

like image 58
Java42 Avatar answered Feb 01 '26 15:02

Java42


Eclipse's source level is a feature allowing code to be written for older versions of Java, using a limited feature-set. For some reason or another, your project got imported, and the source level was set too low. You need to set it higher.

Go to project properties by right-clicking the project in the explorer at left, and select the "java compiler" pane at the left of the settings window.

Set the compliance level and source compatibility to 1.5 or higher (highest is usually OK, though you may want to stay no higher than 1.7 for now)

On the "Java Build Path" pane,"Libraries " tab, make sure that the JRE system library is at least as high as the source compatibility and source levels you set.

like image 35
nanofarad Avatar answered Feb 01 '26 16:02

nanofarad