Questions tagged [java-8]

Use this tag for questions specific to Java 8 which is version 8 (internal number 1.8) of the Java platform, released on 18 March 2014. In most cases, you should also specify the java tag.

Java 8 features the most changes ever to be introduced in a new Java version.

The most important change is the support for functional paradigm through lambda expressions and method references, under Project Lambda. This is the driving new feature of Java 8.

Other features include:

  • A new Date & Time API
  • A new Stream API integrated into the Collections API
  • Project Nashorn, a JavaScript runtime which allows developers to embed JavaScript code within applications
  • A standard API for performing Base64 encoding and decoding
  • Stronger integration with JavaFX
  • Annotations on Java types

Although it was initially advertised to be launched in September 2013, the release was pushed to March 2014 due to security issues. The GA release has been available for download from Oracle's download page since 18 March 2014.

More details on how Java 8 continues to evolve can be found on the official website and on the JDK8 mailing list.

Please keep in mind that the General Availability version of Java 8 doesn't run on Windows XP.

Reference Material

##Frequently Asked Questions

23031 questions
18
votes
1 answer

Gradle + Retrolambda: Fatal Error: Unable to find package java.lang in classpath or bootclasspath

I am trying to integrate gradle-retrolambda in my Android project (following this guide), but I am getting the following error when I run my gradle build :app:compileDebugJava Fatal Error: Unable to find package java.lang in classpath or…
Flo
  • 1,469
  • 1
  • 18
  • 27
18
votes
1 answer

Spring + AspectJ weaving for java 8 using aspectj-maven-plugin

I'm migrating my project from java 7 to java 8 and the problem I have is related to aspectj weaving using aspectj-maven-plugin. I could configure successfuly the weaving using this plugin running on Java 6 and 7 according to Haus documentation. But…
Federico Piazza
  • 30,085
  • 15
  • 87
  • 123
18
votes
3 answers

JDK 1.8 on Linux missing JNI include file

I am trying to compile the following project: https://github.com/entropia/libsocket-can-java I always get this error message? Does anyone know how to fix it, is it possibly a bug in JDK 1.8.0.11 on Linux (x64 Debian Wheezy)? In file included from…
arash javanmard
  • 1,362
  • 2
  • 17
  • 37
18
votes
2 answers

java8: dealing with default methods

While writing a crypto utility class I ran into a problem with the following method: public static void destroy(Key key) throws DestroyFailedException { if(Destroyable.class.isInstance(key)) { ((Destroyable)key).destroy(); …
A4L
  • 17,353
  • 6
  • 49
  • 70
18
votes
3 answers

spring-core 3.2.9 + java 8

We've upgraded our project using spring 3.2.9 to java 8. Once we start using java 8 features spring will no longer start (see stack trace below). I tried to exclude old usages of asm and include the following dependencies:
user3821040
  • 181
  • 1
  • 1
  • 3
18
votes
3 answers

JDK8: Getting back the JDK7 look for javadoc

I find it difficult to read the new look-and-feel in JDK8 javadoc compared to JDK7. Here's a side-by-side example. JDK7: JDK8: JDK8 takes up considerable more space. It now uses the DejaVu font where Arial was previously used. There may be good…
peterh
  • 18,404
  • 12
  • 87
  • 115
18
votes
2 answers

Parallelism and Flatmap in Java 8 Streams

Consider the following example: IntStream.of(-1, 1) .parallel() .flatMap(i->IntStream.range(0,1000).parallel()) .forEach(System.out::println); Does it matter whether I set the inner flag to parallel? The…
Benedikt Bünz
  • 648
  • 7
  • 22
18
votes
2 answers

Scala using Java libraries, taking advantage of lambda expressions support in Java 8

According to: http://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html#lambda-expressions-in-gui-applications Previously: btn.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { …
SpaceMonkey
  • 4,143
  • 5
  • 38
  • 60
18
votes
1 answer

Why is `Stream.collect` type-safe and `Stream.toArray(IntFunction)` is not?

Consider the following code fragment String strings[] = {"test"}; final List collect = java.util.Arrays.stream(strings).collect(java.util.stream.Collectors.toList()); final Double[] array =…
muued
  • 1,666
  • 13
  • 25
18
votes
3 answers

How to check if string matches date pattern using time API?

My program is parsing an input string to a LocalDate object. For most of the time the string looks like 30.03.2014, but occasionally it looks like 3/30/2014. Depending on which, I need to use a different pattern to call…
user1019830
18
votes
4 answers

JDK8 CompletableFuture.supplyAsync how to deal with interruptedException

CompletableFuture.supplyAsync( () -> { transporter.write(req); //here take the value from a blocking queue,will throw a interruptedException return responseQueue.take(); }, executorService); The common method to deal with…
GrapeBaBa
  • 1,391
  • 3
  • 12
  • 22
18
votes
3 answers

Are the Streams in Java 8 monads?

It seems like the Optional in Java 8 is a monad. Are the Streams also monads? Can anyone identify the endofunctor and the two natural transformations in the optional monad?
Ray Tayek
  • 9,841
  • 8
  • 50
  • 90
18
votes
3 answers

Can a lambda be used to change a List's values in-place ( without creating a new list)?

I am trying to determine the correct way of changing all the values in a List using the new lambdas feature in the upcoming release of Java 8 without creating a **new** List. This pertains to times when a List is passed in by a caller and needs to…
The Coordinator
  • 13,007
  • 11
  • 44
  • 73
18
votes
2 answers

Gradle build with Java 8

I'm trying to build Java 8 project with Gradle 1.6, but I'm stuck on this error: Execution failed for task ':ejb:compileJava' invalid target release: 1.8 JAVA_HOME is set as "D:\Program Files\Java\jdk1.8.0", and build.gradle contains these…
perak
  • 1,310
  • 5
  • 20
  • 31
18
votes
3 answers

Java 8 Lambdas: Mapping a Stream to type Integer and then calling sum() won't compile

I was playing around with Java8 lambda expressions. As an example I then tried to sum up the ages persons contained in a list: import java.util.Arrays; import java.util.List; public class Person { public static void main(String[] args) { …
Daniel K.
  • 5,747
  • 3
  • 19
  • 22