简体   繁体   中英

Eclipse not recognizing Java 8 libaries

Oracle Java 8 introduced LocalDateTime, LocalDate, LocalTime, among other classes. I am using Ubuntu 12.04 and so I use Eclipse Indigo, which is available through the software center. I have Oracle Java 8 set as my default:

$ sudo update-alternatives --config java

  Selection    Path                                           Priority   Status

------------------------------------------------------------

* 0            /usr/lib/jvm/java-8-oracle/jre/bin/java         1062      auto mode

  1            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1061      manual mode

  2            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1051      manual mode

  3            /usr/lib/jvm/java-8-oracle/jre/bin/java         1062      manual mode


$ java -version

java version "1.8.0_05"

Java(TM) SE Runtime Environment (build 1.8.0_05-b13)


$ javac -version
javac 1.8.0_05

In Eclipse, Project > Properties > Java Build path, it is using JRE System Library [java-8-oracle].

Yet Eclipse cannot resolve any of these imports:

import java.time.LocalDateTime;
import java.time.LocalDate;
import java.time.LocalTime;

Any idea what might be going on?

As Jigar stated in the comments, you need to install the Java 8 support plugin to enable 1.8 as a compliance level. Alternatively, just grab the latest Luna release candidate which has Java 8 support built-in.

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