Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find java.util.stream in java8

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?

like image 653
Saleh Omar Avatar asked Mar 29 '13 15:03

Saleh Omar


People also ask

Is stream API introduced in Java 8?

Introduced in Java 8, the Stream API is used to process collections of objects. A stream is a sequence of objects that supports various methods which can be pipelined to produce the desired result.

Is Java Util stream package is used for stream API in Java 8?

All the Java Stream API interfaces and classes are in the java. util. stream package. Since we can use primitive data types such as int, long in the collections using auto-boxing and these operations could take a lot of time, there are specific classes for primitive types - IntStream , LongStream and DoubleStream .

What is stream filter in Java 8?

Java stream provides a method filter() to filter stream elements on the basis of given predicate. Suppose you want to get only even elements of your list then you can do this easily with the help of filter method. This method takes predicate as an argument and returns a stream of consisting of resulted elements.

What is Java Util stream?

Java provides a new additional package in Java 8 called java. util. stream. This package consists of classes, interfaces and enum to allows functional-style operations on the elements. You can use stream by importing java.


2 Answers

I had the same problem with Netbeans. It seams that older versions of JDK 8 are not correctly packaged.

I had the same problem with b84, but I installed the build b116 and it is working properly.

PS: I think this is what @rmuller said in his comment

like image 64
gortiz Avatar answered Oct 23 '22 17:10

gortiz


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.

(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 documentation on this issue doesn't mention it!)

like image 44
BlueRaja - Danny Pflughoeft Avatar answered Oct 23 '22 17:10

BlueRaja - Danny Pflughoeft