无法导入 java.time 包
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24518476/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot import java.time package
提问by firerml
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!
我正在使用 NetBeans。我正在尝试import java.time.*
,但 NetBeans(和 DrJava)坚持认为这不存在。我已经安装了 JDK 8,但我不知道如何让程序找到 java.time。帮助!
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).
不管它值多少钱,我在首选项中看到“源”是 JDK 7,但我不知道如何将它设置为 JDK 8(没有选择)。
NetBeans about:
NetBeans 关于:
- 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
- 产品版本:NetBeans IDE 8.0(内部版本 201403101706)
- 更新:NetBeans IDE 更新到版本 NetBeans 8.0 Patch 1.1
- Java:1.7.0_09;Java HotSpot(TM) 64 位服务器 VM 23.5-b02
- 运行时:Java(TM) SE 运行时环境 1.7.0_09-b05
- 系统:运行在amd64上的Windows 7 6.1版;cp1252; en_US (nb)
- 用户目录:C:\Users\Mikhail Firer\AppData\Roaming\NetBeans\8.0
- 缓存目录:C:\Users\Mikhail Firer\AppData\Local\NetBeans\Cache\8.0
回答by Alvaro C.
Working for my. Sorry for my english
为我工作。对不起我的英语不好
- Rigth click in your proyect and select the option Properties
- In the dialog select Build> Compiling
- In the rigth side select JDK 8 o Manager Platformand Add Platformand Java Standard Editionthen select your JDK 8 directory
- 右键单击您的项目并选择选项属性
- 在对话框中选择构建>编译
- 在右侧选择 JDK 8 o Manager Platform和Add Platformand Java Standard Edition然后选择您的 JDK 8 目录
回答by pedram bashiri
java.time package is only available in Java 8, and you're apparently compiling your code using Java 7
java.time 包仅在 Java 8 中可用,您显然是在使用 Java 7 编译代码