Eclipse build path and Java Compiler

Source: Internet
Author: User
Tags unsupported

The project developed in Eclipse has a JDK that can be configured in Java build path, and a Java compiler can be configured with compiler level, which is different, Java compiler The JDK version of level is the version you develop code in eclipse to give you an indication of the error and compile the Java file into a class file, and the version number in the build path is used to indicate the environment you will run in the future.

If the build path version is lower than the compiler version, it will be reported unsupported Major.minor version 51.0 (high version number, JDK7 for example).

Most articles on the web say that the Java compiler level and build path function differently from me. Under their instructions, I tried to set the compiler level to 1.6,build path to 1.7 in eclipse, writing the following program:

 Public class Test {    publicstaticvoid  main (string[] args) {        // TODO auto-generated Method stub        long test = 1234_5678_9012_3456l;  // jdk7 New Syntax         System.out.println (test);}    }

Results The program failed to compile successfully, Eclipse prompt error, forced to run reported the following error

Exception in thread "main" java.lang.Error:Unresolved compilation Problem:     1.7 or greater    at Test.main (Test.java:6)

Even if the system's Java home is set to Jdk7, running with Java commands also reports the above error.

If the compiler level is set to 1.7,build path set to 1.6, Eclipse does not report a write error, but after run, the unsupported Major.minor version 51.0 error is reported.

Eclipse build path and Java Compiler

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.