Setting JDK in Eclipse

前端 未结 6 1374
旧时难觅i
旧时难觅i 2020-11-22 16:37

I have two JDKs, for Java 6 and 7.

I want to build my project using both. Initially we only built against 1.6. I see in my project setting I can select 1.5, 1.6 1.7

6条回答
  •  庸人自扰
    2020-11-22 16:50

    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();
          }        
      }
      

提交回复
热议问题