简体   繁体   中英

Compiler compliance level in Eclipse

I'm using JDK 1.8 version. And had imported some already written code. Got an error like below

The method actionPerformed(ActionEvent) of type new ActionListener(){} must override a superclass method

Googled, tured out that I need to set Compiler compliance level in Eclipse to 1.6 and problem solved.

Got 2 doubts

1) If I set 1.6, How my 1.8 jdk (Installed in my machine) is able to produce 1.6 versions of files and run it too ? Is it possible 1.8 can produce 1.6 versions of java files and run it too ?

2) Is higher level of compliance level can handle lower verions, becasue its derived from lower to higher ? If yes, then why its even required to change the compliance level, if it can be handled ?

Does my doubts makes sense ?

tured out that I need to set Compiler compliance level in Eclipse to 1.6

No, you don't need to do that, and most likely it is a very bad idea . Setting compiler compliance level to 1.6 instructs your modern Java compiler to pretend it is the old Java 6 compiler. This means old code doesn't have to be modified to work with the new language version, but it also means you will be unable to use any language features that have been added to the Java language in the last 15 years . That sounds like a very high price to pay to avoid having to slightly adjust old code to compile under a new Java version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM