Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import java.time package

I'm using NetBeans. I'm trying to import java.time.*, but NetBeans (and DrJava) insists this doesn't exist. I've installed JDK 8, but I don't know how to make the program find java.time. Help!

Edit:

For whatever it's worth, I see in the preferences that "source" is JDK 7, but I don't know how to set it to JDK 8 (there's no option for that).

NetBeans about:

  • Product Version: NetBeans IDE 8.0 (Build 201403101706)
  • Updates: NetBeans IDE is updated to version NetBeans 8.0 Patch 1.1
  • Java: 1.7.0_09; Java HotSpot(TM) 64-Bit Server VM 23.5-b02
  • Runtime: Java(TM) SE Runtime Environment 1.7.0_09-b05
  • System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
  • User directory: C:\Users\Mikhail Firer\AppData\Roaming\NetBeans\8.0
  • Cache directory: C:\Users\Mikhail Firer\AppData\Local\NetBeans\Cache\8.0
like image 215
firerml Avatar asked Dec 11 '25 10:12

firerml


2 Answers

java.time package is only available in Java 8, and you're apparently compiling your code using Java 7

like image 112
pedram bashiri Avatar answered Dec 14 '25 05:12

pedram bashiri


Working for my. Sorry for my english

  1. Rigth click in your proyect and select the option Properties
  2. In the dialog select Build > Compiling
  3. In the rigth side select JDK 8 o Manager Platform and Add Platform and Java Standard Edition then select your JDK 8 directory
like image 35
Alvaro C. Avatar answered Dec 14 '25 06:12

Alvaro C.