在 java8 中找不到 java.util.stream
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15706048/
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
Can't find java.util.stream in java8
提问by Saleh Omar
I have installed jdk-8-ea-bin-b82-windows-x64-21_mar_2013
and IntelliJ IDEA 12.0.4. The strange thing is that I can't find java.util.stream
in the intellisense provided by the IDE. I tried to compile either using the IDE or using the notepad and the compiler but it gives an error complaining that java.util.stream
cannot be found! I have already set the module settings to use Java8 jdk. Any ideas about this problem?
我已经安装jdk-8-ea-bin-b82-windows-x64-21_mar_2013
和IntelliJ IDEA的12.0.4。奇怪的是,我java.util.stream
在IDE提供的intellisense中找不到。我尝试使用 IDE 或使用记事本和编译器进行编译,但它给出了一个错误,抱怨java.util.stream
找不到!我已经将模块设置设置为使用 Java8 jdk。关于这个问题的任何想法?
采纳答案by Saleh Omar
As @rmuller pointed out there was no streams in the early release version that I have downloaded 5 years ago when I asked the question. Short while after I asked the question a new release was available and it contained the streams support.
正如@rmuller 指出的那样,我 5 年前在问这个问题时下载的早期版本中没有流。在我问这个问题后不久,一个新版本可用,它包含流支持。
回答by gortiz
I had the same problem with Netbeans. It seams that older versions of JDK 8 are not correctly packaged.
我在使用 Netbeans 时遇到了同样的问题。看来旧版本的 JDK 8 没有正确打包。
I had the same problem with b84, but I installed the build b116 and it is working properly.
我在 b84 上遇到了同样的问题,但我安装了 build b116 并且它工作正常。
PS: I think this is what @rmuller said in his comment
PS:我认为这是@rmuller 在他的评论中所说的
回答by BlueRaja - Danny Pflughoeft
To change the JDK version, go to File --> Project Structure, and make sure both Project SDK and Project Language Level are set to JDK 8.
要更改 JDK 版本,请转到文件 --> 项目结构,并确保项目 SDK 和项目语言级别都设置为 JDK 8。
(I know you said you set the JDK level in the modules already, but I'm posting this here because there is relatively little information online on how to do that. Even the IDEA documentationon this issue doesn't mention it!)
(我知道你说你已经在模块中设置了 JDK 级别,但我在这里发布这个是因为网上关于如何做到这一点的信息相对较少。甚至关于这个问题的IDEA 文档也没有提到它!)
回答by Sargis
Try to download from: http://jdk8.java.net/lambda/to have lambda and stream support
尝试从:http: //jdk8.java.net/lambda/下载以获得 lambda 和流支持
回答by ke meng
YOU CAN SET PROJECT SETTING IN MODULES
您可以在模块中设置项目设置
THE LANGUAGE LEVEL SET 8-LAMBDAS enter image description here
语言级别设置 8-LAMBDAS 在此处输入图像描述
BEACUSE THE DEFAULT LANGUAGE LEVEL IS 7 -Diamonds
因为默认语言级别是 7 -Diamonds