3 Replies Latest reply on Jul 1, 2014 10:56 PM by theRealPedron

    Please help with my Eclipse problem(Beginner)

    Nhuy Van

      Hi guys, I am not sure if I posed here is correct or not, I have an issue with Java SE 8 in Eclipse, but I can't find the section for Java SE at all. But please kindly help. Here is the problem, I installed Java 1.8_05 in Eclipse, but somehow it doesn't recognize the "default" keyword in an interface at all. I created a simple interface, but it gave a compile-time error as below:


      public interface Simple {

          default void eat() {            //Here, on this line in Eclipse, it highlights the "default" keyword with a red error indicator at the beginning of the line and tells me to delete the "default" token.





      I don't know how to correct this, please please help. Thank you very very much for your time and everything.

        • 1. Re: Please help with my Eclipse problem(Beginner)

          That exception indicates that the compiler being used is NOT Java 8.


          Therefore you must have multiple versions of Java on that machine and Eclipse is using an earlier version.


          Find and remove all of the other Java versions and make sure your environment variables only reference Java 8.


          For further help you need to post in an Eclipse forum since yours is NOT a Java problem.

          • 2. Re: Please help with my Eclipse problem(Beginner)

            Or rather, switch to an IDE that supports Java 8, then set up the project to use that language level and compiler.

            Eclipse uses a built in compiler, not an external one (those are used only as a runtime), and all but the very latest Eclipse versions won't be able to compile to Java 8 simply because they lack the support for it.

            • 3. Re: Please help with my Eclipse problem(Beginner)

              So, just an FYI for using eclipse, the version you are using, and that comes through on your command-line "java -version" may not be the version you're using in Eclipse.


              First, you need to check what version of Java you're using in Eclipse:

              1. Open Eclipse
              2. Browse to the "Preferences" window
              3. Click on "Java"
              4. Click on "Installed JREs"
              5. In this window you will see a list of directories. Each should point to the JAVE_HOME directory of a separate installation. Do you see the checked one pointing to a Java 8 installation? If NO, then do the following steps:
                1. Click 'Add'
                2. Click on 'Standard VM' and 'Next'
                3. Under the 'JRE_HOME' field, click on 'Directory'
                4. Browse to the JAVA_HOME directory (this is the base directory, where your 'bin', 'include', and 'lib' directories reside) for your Java 8 installation
                5. Once you click it, if it's a valid JAVA_HOME directory, all the info should fill in automatically.
                6. Click Finish
                7. Once you finish this, make sure this entry is checked. Click OK.
                8. Go back and try again. GOOD LUCK!