SlideShare a Scribd company logo
1 of 34
Download to read offline
New Features
Haim Michael
June 4th
, 2019
All logos, trade marks and brand names used in this presentation belong
to the respective owners.
lifemichael
Java 11
1st Part https://youtu.be/zggphqAcUvw
2nd Part https://youtu.be/ViL0flSGrGY
© 1996-2018 All Rights Reserved.
Haim Michael Introduction
● Snowboarding. Learning. Coding. Teaching. More
than 20 years of Practical Experience.
lifemichael
© 1996-2018 All Rights Reserved.
Haim Michael Introduction
● Professional Certifications
Zend Certified Engineer in PHP
Certified Java Professional
Certified Java EE Web Component Developer
OMG Certified UML Professional
● MBA (cum laude) from Tel-Aviv University
Information Systems Management
lifemichael
© 2008 Haim Michael 20151026
Oracle JDK is not Free
 As of Java 11, the Oracle JDK would no longer be free
for commercial use.
 The Open JDK continues to be free. We can use it
instead. However, we won't get nor security updates
and nor any update at all.
© 2008 Haim Michael 20151026
Running Java File
 We can avoid the compilation phase. We can compile
and execute in one command. We use the java
command. It will implicitly compile without saving the
.class file.
© 2008 Haim Michael 20151026
Running Java File
© 2008 Haim Michael 20151026
Java String Methods
 The isBlank() method checks whether the string is
an empty string, meaning... whether the string solely
includes zero or more blanks. String with only white
characters is treated as a blank string.
public class Program {
public static void main(String args[]) {
var a = "";
var b = " ";
System.out.println(a.isBlank());
System.out.println(b.isBlank());
}
}
© 2008 Haim Michael 20151026
Java String Methods
 The lines() method returns a reference for a stream
of strings that are substrings we received after splitting
by lines.
public class Program {
public static void main(String args[]) {
var a = "wenlovenjavanandnkotlin";
var stream = a.lines();
stream.forEach(str->System.out.println(str));
}
}
© 2008 Haim Michael 20151026
Java String Methods
 The strip(), stripLeading()and the
stripTrailing methods remove white spaces from
the beginning, the ending and the remr of the string. It
is a 'Unicode-Aware' evolution of trim();
public class Program {
public static void main(String args[]) {
var a = " we love kotlin ";
var b = a.strip();
System.out.println("###"+b+"###");
}
}
© 2008 Haim Michael 20151026
Java String Methods
 The repeat() method repeats the string on which it is
invoked the number of times it receives.
public class Program {
public static void main(String args[]) {
var a = "love ";
var b = a.repeat(2);
System.out.println(b);
}
}
© 2008 Haim Michael 20151026
Using var in Lambda Expressions
 As of Java 11 we can use the var keyword within
lambda expressions.
interface Calculation {
public int calc(int a,int b);
}
public class Program {
public static void main(String args[]) {
Calculation f = (var a, var b)-> a+b;
System.out.println(f.calc(4,5));
}
}
© 2008 Haim Michael 20151026
Using var in Lambda Expressions
 When using var in a lambda expression we must use
it on all parameters and we cannot mix it with using
specific types.
© 2008 Haim Michael 20151026
Inner Classes Access Control
 Code written in methods defined inside inner class can
access members of the outer class, even if these
members are private.
class Outer
{
private void a() {}
class Inner {
void b() {
a();
}
}
}
© 2008 Haim Michael 20151026
Inner Classes Access Control
 As of Java 11, there are new methods in Class class
that assist us with getting information about the created
nest. These methods include the following:
getNestHost(), getNestMembers() and
isNestemateOf().
© 2008 Haim Michael 20151026
Epsilon
 As of Java 11, the JVM has an experimental feature
that allows us to run the JVM without any actual
memory reclamation.
 The goal is to provide a completely passive garbage
collector implementation with a bounded allocation limit
and the lowest latency overhead possible.
https://openjdk.java.net/jeps/318
© 2008 Haim Michael 20151026
Deprecated Modules Removal
 As of Java 11, Java EE and CORBA modules that
were already marked as deprecated in Java 9 are now
completely removed.
java.xml.ws
java.xml.bind
java.activation
java.xml.ws.annotation
java.corba
java.transaction
java.se.ee
jdk.xml.ws
jdk.xml.bind
© 2008 Haim Michael 20151026
Flight Recorder
 The Flight Recorder is a profiling tool with a negligible
overhead below 1%. This extra ordinary overhead
allows us to use it even in production.
 The Flight Recorder, also known as JFR, used to be a
commercial add-on in Oracle JDK. It was recently open
sourced.
© 2008 Haim Michael 20151026
Flight Recorder
 Using the jps command we can get the process id of
our Java program.
© 2008 Haim Michael 20151026
Flight Recorder
 Using the jcmd command we can perform various
commands, such as jcmd 43659 JFR.start
© 2008 Haim Michael 20151026
Flight Recorder
 Using the jcmd command together with JFR.dump we
can dump all data to a textual file we choose its name
and it location on our computer.
© 2008 Haim Michael 20151026
Flight Recorder
 There are various possibilities to process the new
created data file.
https://github.com/lhotari/jfr-report-tool
© 2008 Haim Michael 20151026
The HTTP Client
 As of Java 11, the HTTP Client API is more
standardized.
 The new API supports both HTTP/1.1 and HTTP/2.
 The new API also supports HTML5 WebSockets.
© 2008 Haim Michael 20151026
The HTTP Client
 As of Java 11, the HTTP Client API is more
standardized. The new API supports both HTTP/1.1
and HTTP/2. The new API also supports HTML5
WebSockets.
© 2008 Haim Michael 20151026
The HTTP Client
package com.lifemichael.samples;
import java.io.IOException;
import java.net.http.*;
import java.net.*;
import java.net.http.HttpResponse.*;
public class HTTPClientDemo {
public static void main(String args[]) {
HttpClient httpClient = HttpClient.newBuilder().build();
© 2008 Haim Michael 20151026
The HTTP Client
HttpRequest request = HttpRequest.newBuilder().uri(URI.create(
"http://www.abelski.com/courses/dom/lib_doc.xml"))
.GET()
.build();
try {
HttpResponse<String> response = httpClient.send(
request, BodyHandlers.ofString());
System.out.println(response.body());
System.out.println(response.statusCode());
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
© 2008 Haim Michael 20151026
The HTTP Client
 The new HTTP Client allows us to initiate an
asynchronous HTTP request.
HttpClient
.sendAsync(request,BodyHandlers.ofString())
.thenAccept(response -> {
System.out.println(response.body());
//..
});
© 2008 Haim Michael 20151026
The HTTP Client
 The new HTTP Client supports the WebSocket
protocol.
HttpClient httpClient = HttpClient.newBuilder()
.executor(executor).build();
Builder webSocketBuilder = httpClient.newWebSocketBuilder();
WebSocket webSocket = webSocketBuilder
.buildAsync(
URI.create("wss://echo.websocket.org"), … ).join();
© 2008 Haim Michael 20151026
Nashorn is Deprecated
 As of Java 11, the Nashorn JavaScript engine and
APIs are deprecated. Most likely, in future versions of
the JDK.
© 2008 Haim Michael 20151026
The ZGC Scalable Low Latency GC
 As of Java 11, we can use the ZGC. This new GC is
available as an experimental feature.
 ZGC is a scalable low latency garbage collector. It
performs the expensive work concurrently without
stopping the execution of application threads for more
than 10ms.
© 2008 Haim Michael 20151026
The ZGC Scalable Low Latency GC
 ZGC is suitable especially for applications that require
low latency and/or use a very large heap (multi-
terabytes).
© 2008 Haim Michael 20151026
Files Reading and Writing
 Java 11 introduces two new methods that significantly
assist with reading and writing strings from and to files.
readString()
writeString()
© 2008 Haim Michael 20151026
Files Reading and Writing
public class FilesReadingDemo {
public static void main(String args[]) {
try {
Path path = FileSystems.getDefault()
.getPath(".", "welove.txt");
String str = Files.readString(path);
System.out.println(str);
} catch (IOException e) {
e.printStackTrace();
}
}
© 2008 Haim Michael 20151026
Files Reading and Writing
public class FilesWritingDemo {
public static void main(String args[]) {
Path path = FileSystems.getDefault()
.getPath(".", "welove.txt");
try {
Files.writeString(path,
"we love php", StandardOpenOption.APPEND);
} catch (IOException e) {
e.printStackTrace();
}
}
}
© 2008 Haim Michael 20151026
Q&A
Thanks for attending our meetup! I hope you enjoyed! I
will be more than happy to get feedback.
Haim Michael
haim.michael@lifemichael.com
0546655837

More Related Content

What's hot

What's hot (20)

Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & Streams
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Java SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionJava SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introduction
 
Java 10 New Features
Java 10 New FeaturesJava 10 New Features
Java 10 New Features
 
Intro to Reactive Programming
Intro to Reactive ProgrammingIntro to Reactive Programming
Intro to Reactive Programming
 
Java 9/10/11 - What's new and why you should upgrade
Java 9/10/11 - What's new and why you should upgradeJava 9/10/11 - What's new and why you should upgrade
Java 9/10/11 - What's new and why you should upgrade
 
Spring boot jpa
Spring boot jpaSpring boot jpa
Spring boot jpa
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
 
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin CoroutinesThreading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
 
Java 8 Streams
Java 8 StreamsJava 8 Streams
Java 8 Streams
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
 
Express js
Express jsExpress js
Express js
 

Similar to Java11 New Features

Introduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry PiIntroduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry Pi
Bruno Borges
 
Java rmi example program with code
Java rmi example program with codeJava rmi example program with code
Java rmi example program with code
kamal kotecha
 
Networking and Data Access with Eqela
Networking and Data Access with EqelaNetworking and Data Access with Eqela
Networking and Data Access with Eqela
jobandesther
 

Similar to Java11 New Features (20)

Asynchronous JavaScript Programming
Asynchronous JavaScript ProgrammingAsynchronous JavaScript Programming
Asynchronous JavaScript Programming
 
Introduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry PiIntroduction to JavaFX on Raspberry Pi
Introduction to JavaFX on Raspberry Pi
 
Mastering the Sling Rewriter by Justin Edelson
Mastering the Sling Rewriter by Justin EdelsonMastering the Sling Rewriter by Justin Edelson
Mastering the Sling Rewriter by Justin Edelson
 
Mastering the Sling Rewriter
Mastering the Sling RewriterMastering the Sling Rewriter
Mastering the Sling Rewriter
 
Node.js primer for ITE students
Node.js primer for ITE studentsNode.js primer for ITE students
Node.js primer for ITE students
 
Traffic Management In The Cloud
Traffic Management In The CloudTraffic Management In The Cloud
Traffic Management In The Cloud
 
Java and Serverless - A Match Made In Heaven, Part 2
Java and Serverless - A Match Made In Heaven, Part 2Java and Serverless - A Match Made In Heaven, Part 2
Java and Serverless - A Match Made In Heaven, Part 2
 
JavaFX8 TestFX - CDI
JavaFX8   TestFX - CDIJavaFX8   TestFX - CDI
JavaFX8 TestFX - CDI
 
Node JS Crash Course
Node JS Crash CourseNode JS Crash Course
Node JS Crash Course
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start) Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start)
 
Java rmi example program with code
Java rmi example program with codeJava rmi example program with code
Java rmi example program with code
 
Open Source XMPP for Cloud Services
Open Source XMPP for Cloud ServicesOpen Source XMPP for Cloud Services
Open Source XMPP for Cloud Services
 
Maximize the power of OSGi in AEM
Maximize the power of OSGi in AEM Maximize the power of OSGi in AEM
Maximize the power of OSGi in AEM
 
Node.js primer
Node.js primerNode.js primer
Node.js primer
 
Java 9 features
Java 9 featuresJava 9 features
Java 9 features
 
Networking and Data Access with Eqela
Networking and Data Access with EqelaNetworking and Data Access with Eqela
Networking and Data Access with Eqela
 
Node.js Workshop
Node.js WorkshopNode.js Workshop
Node.js Workshop
 
InterConnect2016: WebApp Architectures with Java and Node.js
InterConnect2016: WebApp Architectures with Java and Node.jsInterConnect2016: WebApp Architectures with Java and Node.js
InterConnect2016: WebApp Architectures with Java and Node.js
 
Java vs. Java Script for enterprise web applications - Chris Bailey
Java vs. Java Script for enterprise web applications - Chris BaileyJava vs. Java Script for enterprise web applications - Chris Bailey
Java vs. Java Script for enterprise web applications - Chris Bailey
 

More from Haim Michael

More from Haim Michael (20)

Anti Patterns
Anti PatternsAnti Patterns
Anti Patterns
 
Virtual Threads in Java
Virtual Threads in JavaVirtual Threads in Java
Virtual Threads in Java
 
MongoDB Design Patterns
MongoDB Design PatternsMongoDB Design Patterns
MongoDB Design Patterns
 
Introduction to SQL Injections
Introduction to SQL InjectionsIntroduction to SQL Injections
Introduction to SQL Injections
 
Record Classes in Java
Record Classes in JavaRecord Classes in Java
Record Classes in Java
 
Microservices Design Patterns
Microservices Design PatternsMicroservices Design Patterns
Microservices Design Patterns
 
Structural Pattern Matching in Python
Structural Pattern Matching in PythonStructural Pattern Matching in Python
Structural Pattern Matching in Python
 
Unit Testing in Python
Unit Testing in PythonUnit Testing in Python
Unit Testing in Python
 
OOP Best Practices in JavaScript
OOP Best Practices in JavaScriptOOP Best Practices in JavaScript
OOP Best Practices in JavaScript
 
Java Jump Start
Java Jump StartJava Jump Start
Java Jump Start
 
JavaScript Jump Start 20220214
JavaScript Jump Start 20220214JavaScript Jump Start 20220214
JavaScript Jump Start 20220214
 
Bootstrap Jump Start
Bootstrap Jump StartBootstrap Jump Start
Bootstrap Jump Start
 
What is new in PHP
What is new in PHPWhat is new in PHP
What is new in PHP
 
What is new in Python 3.9
What is new in Python 3.9What is new in Python 3.9
What is new in Python 3.9
 
Programming in Python on Steroid
Programming in Python on SteroidProgramming in Python on Steroid
Programming in Python on Steroid
 
The matplotlib Library
The matplotlib LibraryThe matplotlib Library
The matplotlib Library
 
Pandas meetup 20200908
Pandas meetup 20200908Pandas meetup 20200908
Pandas meetup 20200908
 
The num py_library_20200818
The num py_library_20200818The num py_library_20200818
The num py_library_20200818
 
Jupyter notebook 20200728
Jupyter notebook 20200728Jupyter notebook 20200728
Jupyter notebook 20200728
 
The Power of Decorators in Python [Meetup]
The Power of Decorators in Python [Meetup]The Power of Decorators in Python [Meetup]
The Power of Decorators in Python [Meetup]
 

Recently uploaded

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 

Java11 New Features

  • 1. New Features Haim Michael June 4th , 2019 All logos, trade marks and brand names used in this presentation belong to the respective owners. lifemichael Java 11 1st Part https://youtu.be/zggphqAcUvw 2nd Part https://youtu.be/ViL0flSGrGY
  • 2. © 1996-2018 All Rights Reserved. Haim Michael Introduction ● Snowboarding. Learning. Coding. Teaching. More than 20 years of Practical Experience. lifemichael
  • 3. © 1996-2018 All Rights Reserved. Haim Michael Introduction ● Professional Certifications Zend Certified Engineer in PHP Certified Java Professional Certified Java EE Web Component Developer OMG Certified UML Professional ● MBA (cum laude) from Tel-Aviv University Information Systems Management lifemichael
  • 4. © 2008 Haim Michael 20151026 Oracle JDK is not Free  As of Java 11, the Oracle JDK would no longer be free for commercial use.  The Open JDK continues to be free. We can use it instead. However, we won't get nor security updates and nor any update at all.
  • 5. © 2008 Haim Michael 20151026 Running Java File  We can avoid the compilation phase. We can compile and execute in one command. We use the java command. It will implicitly compile without saving the .class file.
  • 6. © 2008 Haim Michael 20151026 Running Java File
  • 7. © 2008 Haim Michael 20151026 Java String Methods  The isBlank() method checks whether the string is an empty string, meaning... whether the string solely includes zero or more blanks. String with only white characters is treated as a blank string. public class Program { public static void main(String args[]) { var a = ""; var b = " "; System.out.println(a.isBlank()); System.out.println(b.isBlank()); } }
  • 8. © 2008 Haim Michael 20151026 Java String Methods  The lines() method returns a reference for a stream of strings that are substrings we received after splitting by lines. public class Program { public static void main(String args[]) { var a = "wenlovenjavanandnkotlin"; var stream = a.lines(); stream.forEach(str->System.out.println(str)); } }
  • 9. © 2008 Haim Michael 20151026 Java String Methods  The strip(), stripLeading()and the stripTrailing methods remove white spaces from the beginning, the ending and the remr of the string. It is a 'Unicode-Aware' evolution of trim(); public class Program { public static void main(String args[]) { var a = " we love kotlin "; var b = a.strip(); System.out.println("###"+b+"###"); } }
  • 10. © 2008 Haim Michael 20151026 Java String Methods  The repeat() method repeats the string on which it is invoked the number of times it receives. public class Program { public static void main(String args[]) { var a = "love "; var b = a.repeat(2); System.out.println(b); } }
  • 11. © 2008 Haim Michael 20151026 Using var in Lambda Expressions  As of Java 11 we can use the var keyword within lambda expressions. interface Calculation { public int calc(int a,int b); } public class Program { public static void main(String args[]) { Calculation f = (var a, var b)-> a+b; System.out.println(f.calc(4,5)); } }
  • 12. © 2008 Haim Michael 20151026 Using var in Lambda Expressions  When using var in a lambda expression we must use it on all parameters and we cannot mix it with using specific types.
  • 13. © 2008 Haim Michael 20151026 Inner Classes Access Control  Code written in methods defined inside inner class can access members of the outer class, even if these members are private. class Outer { private void a() {} class Inner { void b() { a(); } } }
  • 14. © 2008 Haim Michael 20151026 Inner Classes Access Control  As of Java 11, there are new methods in Class class that assist us with getting information about the created nest. These methods include the following: getNestHost(), getNestMembers() and isNestemateOf().
  • 15. © 2008 Haim Michael 20151026 Epsilon  As of Java 11, the JVM has an experimental feature that allows us to run the JVM without any actual memory reclamation.  The goal is to provide a completely passive garbage collector implementation with a bounded allocation limit and the lowest latency overhead possible. https://openjdk.java.net/jeps/318
  • 16. © 2008 Haim Michael 20151026 Deprecated Modules Removal  As of Java 11, Java EE and CORBA modules that were already marked as deprecated in Java 9 are now completely removed. java.xml.ws java.xml.bind java.activation java.xml.ws.annotation java.corba java.transaction java.se.ee jdk.xml.ws jdk.xml.bind
  • 17. © 2008 Haim Michael 20151026 Flight Recorder  The Flight Recorder is a profiling tool with a negligible overhead below 1%. This extra ordinary overhead allows us to use it even in production.  The Flight Recorder, also known as JFR, used to be a commercial add-on in Oracle JDK. It was recently open sourced.
  • 18. © 2008 Haim Michael 20151026 Flight Recorder  Using the jps command we can get the process id of our Java program.
  • 19. © 2008 Haim Michael 20151026 Flight Recorder  Using the jcmd command we can perform various commands, such as jcmd 43659 JFR.start
  • 20. © 2008 Haim Michael 20151026 Flight Recorder  Using the jcmd command together with JFR.dump we can dump all data to a textual file we choose its name and it location on our computer.
  • 21. © 2008 Haim Michael 20151026 Flight Recorder  There are various possibilities to process the new created data file. https://github.com/lhotari/jfr-report-tool
  • 22. © 2008 Haim Michael 20151026 The HTTP Client  As of Java 11, the HTTP Client API is more standardized.  The new API supports both HTTP/1.1 and HTTP/2.  The new API also supports HTML5 WebSockets.
  • 23. © 2008 Haim Michael 20151026 The HTTP Client  As of Java 11, the HTTP Client API is more standardized. The new API supports both HTTP/1.1 and HTTP/2. The new API also supports HTML5 WebSockets.
  • 24. © 2008 Haim Michael 20151026 The HTTP Client package com.lifemichael.samples; import java.io.IOException; import java.net.http.*; import java.net.*; import java.net.http.HttpResponse.*; public class HTTPClientDemo { public static void main(String args[]) { HttpClient httpClient = HttpClient.newBuilder().build();
  • 25. © 2008 Haim Michael 20151026 The HTTP Client HttpRequest request = HttpRequest.newBuilder().uri(URI.create( "http://www.abelski.com/courses/dom/lib_doc.xml")) .GET() .build(); try { HttpResponse<String> response = httpClient.send( request, BodyHandlers.ofString()); System.out.println(response.body()); System.out.println(response.statusCode()); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }
  • 26. © 2008 Haim Michael 20151026 The HTTP Client  The new HTTP Client allows us to initiate an asynchronous HTTP request. HttpClient .sendAsync(request,BodyHandlers.ofString()) .thenAccept(response -> { System.out.println(response.body()); //.. });
  • 27. © 2008 Haim Michael 20151026 The HTTP Client  The new HTTP Client supports the WebSocket protocol. HttpClient httpClient = HttpClient.newBuilder() .executor(executor).build(); Builder webSocketBuilder = httpClient.newWebSocketBuilder(); WebSocket webSocket = webSocketBuilder .buildAsync( URI.create("wss://echo.websocket.org"), … ).join();
  • 28. © 2008 Haim Michael 20151026 Nashorn is Deprecated  As of Java 11, the Nashorn JavaScript engine and APIs are deprecated. Most likely, in future versions of the JDK.
  • 29. © 2008 Haim Michael 20151026 The ZGC Scalable Low Latency GC  As of Java 11, we can use the ZGC. This new GC is available as an experimental feature.  ZGC is a scalable low latency garbage collector. It performs the expensive work concurrently without stopping the execution of application threads for more than 10ms.
  • 30. © 2008 Haim Michael 20151026 The ZGC Scalable Low Latency GC  ZGC is suitable especially for applications that require low latency and/or use a very large heap (multi- terabytes).
  • 31. © 2008 Haim Michael 20151026 Files Reading and Writing  Java 11 introduces two new methods that significantly assist with reading and writing strings from and to files. readString() writeString()
  • 32. © 2008 Haim Michael 20151026 Files Reading and Writing public class FilesReadingDemo { public static void main(String args[]) { try { Path path = FileSystems.getDefault() .getPath(".", "welove.txt"); String str = Files.readString(path); System.out.println(str); } catch (IOException e) { e.printStackTrace(); } }
  • 33. © 2008 Haim Michael 20151026 Files Reading and Writing public class FilesWritingDemo { public static void main(String args[]) { Path path = FileSystems.getDefault() .getPath(".", "welove.txt"); try { Files.writeString(path, "we love php", StandardOpenOption.APPEND); } catch (IOException e) { e.printStackTrace(); } } }
  • 34. © 2008 Haim Michael 20151026 Q&A Thanks for attending our meetup! I hope you enjoyed! I will be more than happy to get feedback. Haim Michael haim.michael@lifemichael.com 0546655837