2

I have been programming in Eclipse for a coupe of weeks. I had to remove Eclipse and Java for software update. However after I reinstalled Eclipse (Indigo) and Java Jdk (Java SE 8 (MacOS X Default)) I started to get errors.

The printer, scanner and object oriented programming method works fine but the Swing Components throw errors. Everytime I use method such as this.add(confirmButton); I get errors. The Error is :

The type javax.swing.JComponent cannot be resolved. It is indirectly referenced from required .class files.

The internet suggested to fix the Build Path but I am only allowed to Use the default Java SE 8 because other execution environment gives an error

No JREs in workspace compatible with specified execution environment: JavaSE-1.7.

tobias_k
  • 81,265
  • 12
  • 120
  • 179
  • 1
    Do you import Swing classes? – PM 77-1 Apr 20 '15 at 16:47
  • 2
    go to windows properties, build path, click on libraries tab. click on jdk/jre entry and click on remove. click on add library. select java system (or something like that) pick the required jdk version, click apply and ok – Hector Apr 20 '15 at 16:48
  • I don't know whether you meant to attach an 'android' tag to this question; if so, note that there is no Swing in the android UI. – NickT Apr 20 '15 at 17:30
  • Yes I imported the swing classes. And about the android tag, I know it's irrelevent. please ignore. – Rashul Rajbhandari Apr 20 '15 at 18:29
  • i did that. went to the build path and removed the libraries and tried to select the JRE system Library, then under execution environment I cannot select any of the environments as it shows - No JREs in workspace compatible with specified execution environment: ... @Hector – Rashul Rajbhandari Apr 20 '15 at 18:31
  • Indigo does not work with Java 8. You have to use a newer Eclipse, such as Luna. Not sure if this is the error, though, as I think that this should raise _way_ more errors. Are you sure you are still using Eclipse indigo? – tobias_k Apr 20 '15 at 19:36
  • When you can update your Java SDK to Java8, why not use an updated version of eclipse also. Both Kepler and Luna are Java 8 compatibles. – Amitesh Rai Apr 20 '15 at 19:37

1 Answers1

0

Not entirely sure if this is the problem, but as far as I know, Eclipse Indigo is way to old -- four year by now! It was outdated even before Java 8 arrived and never got support (like Kepler got, via a patch) for the new language features, such as default methods on interfaces and the like.

If you want to use Java 8, you should use a newer version of Eclipse. The current version that will properly work with Java 8 is Eclipse Luna (4.4).

tobias_k
  • 81,265
  • 12
  • 120
  • 179
  • Thank you so much. I installed the lates Eclipse Lune and everything works fine now. I guess the problem was that the Eclipse Indigo was configured to support the Java 8. Thank you guys. – Rashul Rajbhandari Apr 21 '15 at 07:08