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