score:170

Accepted answer

you manage the list of available compilers in the window -> preferences -> java -> installed jre's tab.

in the project build path configuration dialog, under the libraries tab, you can delete the entry for jre system library, click on add library and choose the installed jre to compile with. some compilers can be configured to compile at a back-level compiler version. i think that's why you're seeing the addition version options.

score:3

jdk 1.8 have some more enrich feature which doesn't support to many eclipse .

if you didn't find java compliance level as 1.8 in java compiler ,then go ahead and install the below eclipse 32bit or 64 bit depending on your system supports.

  1. install jdk 1.8 and then set the java_home and classpath in environment variable.
  2. download eclipse-jee-neon-3-win32 and unzip : supports to java 1.8
  3. or download oracle enterprise pack for eclipse (12.2.1.5) and unzip :supports java 1.8 with 64 bit os
  4. right click your project > properties
  5. select “java compiler” on left and set java compliance level to 1.8 [select from the dropdown 1.8]
  6. try running one java program supports to java 8 like lambda expression as below and if no compilation error ,means your eclipse supports to java 1.8, something like this:

    interface testi{
        void show();
    }
    
    /*class a implements testi{
        public void show(){
            system.out.println("hello");
        }
    }*/
    
    public class lambdademo1 {
        public static void main(string[] args) {
            testi test ;
            /*test= new a();
            test.show();*/
            test = () ->system.out.println("hello,how are you?"); //lambda 
            test.show();
        }        
    }
    

score:4

eclipse's compiler can assure that your java sources conform to a given jdk version even if you don't have that version installed. this feature is useful for ensuring backwards compatibility of your code.

your code will still be compiled and run by the jdk you've selected.

score:5

configuring jdks

  1. windows -> preferences -> installed jres, to configured the installed jdks
  2. project properties, java compiler, enable project specific settings (or configure workspace settings), jdk compliance
  3. project properties, java build path, libraries, add library, jre system library, workspace default or alternate jre (one of the jres configured in

maven

but if you are using maven, provided that you have your latest jre (windows/preferences/installed jres) -for example jdk 1.8

you can select the level 1.6, 1.7, 1.8 by configuring the maven-compiler-plugin source and target attributes, like this

            <plugin>
                <artifactid>maven-compiler-plugin</artifactid>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

and ideally, if you have a parent pom, you can do it for all the modules (eclipse projects) in the parent pom, in one single place.

source and target if we want to use the java 8 language features the –source should be set to 1.8. also, for the compiled classes to be compatible with jvm 1.8, the –target value should be 1.8.

updating jre library that is broken in many projects at once (with maven)

rather than updating one by one the jre library, let maven do it for you.

selecting the projects and right-clicking for maven -> update project, will set the system library to the path of the installed jdk, in case the paths are broken (because you installed a new jdk or imported from another computer, etc.) and set the jdk compliance according to the maven source and target setting in the pom.

score:31

to tell eclipse to use jdk, you have to follow the below steps.

  1. select the window menu and then select preferences. you can see a dialog box.
  2. then select java ---> installed jre’s
  3. then click add and select standard vm then click next
  4. in the jre home, navigate to the folder you’ve installed the jdk (for example, in my system my jdk was in c:\program files\java\jdk1.8.0_181\ )
  5. now click on finish.

after completing the above steps, you are done now and eclipse will start using the selected jdk for compilation.

score:92

some additional steps may be needed to set both the project and default workspace jre correctly, as mayoman mentioned. here is the complete sequence in eclipse luna:

  • right click your project > properties
  • select “java build path” on left, then “jre system library”, click edit…
  • select "workspace default jre"
  • click "installed jres"
  • if you see jre you want in the list select it (selecting a jdk is ok too)
  • if not, click search…, navigate to computer > windows c: > program files > java, then click ok
  • now you should see all installed jres, select the one you want
  • click ok/finish a million times

easy.... not.


Related Query

More Query from same tag