Reputation: 63
I am working with Java and trying to write a very simple test code like this to test LocalDate
package com.journaldev.java8.time;
import java.time.LocalDate;
import java.time.Month;
import java.time.ZoneId;
public class calendartest {
public static void main(String[] args) {
// Current Date
LocalDate today = LocalDate.now();
System.out.println("Current Date=" + today);
}
}
I am sure that my java version is 8 because I checked by cmd and here is the result
But unfortunately, when I ran my code, the result is
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
LocalDate cannot be resolved to a type
LocalDate cannot be resolved
Could you please give me some comments ? Thank you very much!
Upvotes: 1
Views: 8222
Reputation: 63
Thanks all for your comments. Here is my answer for my problem after 4 hours, finally I found that, I used Eclipse Helios 2010, so that I can not upgrade from Jdk 1.7 to Jdk 1.8. When I changed FROM Eclipse Helios to Eclipse Luna, ALL my problems have been gone. By the way thanks for your comments and wish you all the best.
Upvotes: 1
Reputation: 3679
I can't see that on the image you uploaded, but be sure that source code file goes under src/default package. It should not be in the project's root directory.
To change the Java Version of project you can follow instructions given on this link : https://www.baeldung.com/eclipse-change-java-version.
By the way, I see that you checked "Use default compilance setting" checkbox, that is why your change is not applied. Uncheck that option and try again.
Upvotes: 1