JDK Tutorials - Herong's Tutorial Examples

http://www.herongyang.com/JDK

Copyright © 2003-2018 by Dr. Herong Yang. All rights reserved.

JDK Tutorials This book is a collection of tutorial notes and sample codes written by the author while he was learning JDK (Java Development Kit) core libraries himself. Topics include Time and Calendar, Internationalization, Unnamed Packages, Collections, Character Set and Encoding, Logging, XML related technologies: DOM, SAX, DTD, XSD, and XSL, Cryptography, Certificates, Key stores, Cipher and Encryption, Socket communication, SSL and HTTPS.

Table of Contents

About This JDK Tutorial Book

JDK (Java Development Kit)

What Is JDK

Downloading and Installing JDK 10

Writing My First Java Program

Adding JDK "bin" Directory to Path Setting

JDK Documentation Installation

Java Date-Time API

What Is Date-Time API

java.time.Instant - Representing a Moment of Time

java.time.Instant Usage Examples

java.time.Instant - get(INSTANT_SECONDS) Error

Converting java.util.Date to java.time.Instant

java.time.ZonedDateTime - Calendar and Timezone

java.time.ZonedDateTime Usage Examples

Converting java.util.GregorianCalendar to java.time.ZonedDateTime

java.time.OffsetDateTime - Calendar and UTC Offset

java.time.OffsetDateTime Usage Examples

java.time.LocalDateTime - Local Date and time without Timezone

Partial Date and Time Objects and Classes

java.time.format.DateTimeFormatter - Date-Time Strings

java.time.Duration - Time Durations

java.time.Duration Usage Examples

java.time.Period - Periods in Days and Months

java.time.Period Usage Examples

Date, Time and Calendar Classes

java.util.Date - JDK Class to Measure Date and Time

java.util.Calendar - The Abstract Calendar Class

java.util.Calendar.add() - Calendar Manipulation Method

Date and Time Object and String Conversion

java.util.DateFormat - Formatting Date Objects to Strings

java.util.SimpleDateFormat.parse() - Parsing Date Strings to Objects

Number Object and Numeric String Conversion

java.util.NumberFormat - Formatting Numeric Values to Strings

java.util.DecimalFormat.parse() - Parsing Strings to Number Objects

Locales, Localization Methods and Resource Bundles

java.util.Locale - Localization and Internationalization

Locale Sensitive Operations

java.util.ResourceBundle - Resource Bundle Abstract Class

java.util.ListResourceBundle - Resource Bundles as Lists

java.util.PropertyResourceBundle - Resource Bundles as Properties Files

java.util.ResourceBundle.getBundle() - Retrieving Resource Bundles

Calling and Importing Classes Defined in Unnamed Packages

What Is an Unnamed Package?

One Class in an Unnamed Package - Hello.java

Two Classes in Unnamed Packages - Hello.java and CallingHello.java

Importing Classes Defined in Unnamed Packages

Importing Classes from Unnamed to Named Packages

Importing Classes from Unnamed to Named Packages - JDK 1.4.1

HashSet, Vector, HashMap and Collection Classes

Types of Collections-of-Elements

Data Structures of Collection Implementations

Collection Implementations in JDK

Search Operation Performance of Different Collection Classes

Comparable Interface and compareTo() Method

Character Set Encoding Classes and Methods

What Is Character Encoding?

Supported Character Encodings in JDK

Charset.encode() - Method to Encode Characters

Running EncodingSampler.java with CP1252 Encoding

Running EncodingSampler.java with ISO-8859-1 and US-ASCII

Running EncodingSampler.java with UTF-8, UTF-16, UTF16-BE

Running EncodingSampler.java with GB18030

Charset.decode() - Method to Decode Byte Sequences

Character Set Encoding Maps

Character Set Encoding Map Analyzer

Character Set Encoding Maps - US-ASCII and ISO-8859-1/Latin 1

Character Set Encoding Maps - CP1252/Windows-1252

Character Set Encoding Maps - Unicode UTF-8

Character Set Encoding Maps - Unicode UTF-16, UTF-16LE, UTF-16BE

Character Counter Program for Any Given Encoding

Character Set Encoding Comparison

Encoding Conversion Programs for Encoded Text Files

\uxxxx - Entering Unicode Data in Java Programs

HexWriter.java - Converting Encoded Byte Sequences to Hex Values

EncodingConverter.java - Encoding Conversion Sample Program

Viewing Encoded Text Files in Web Browsers

Unicode Signs in Different Encodings

Java Logging

Socket Network Communication

What Is a Socket?

Establishing a Socket Communication Link

ReverseEchoer.java - A Simple Server Socket Application

SocketClient.java - A Simple Client Socket Application

ReverseEchoServer.java - A Multi-Connection Socket Server

Binding Sockets to Specific Ports

Datagram Network Communication

What Is a Datagram?

Establishing a Datagram Communication Link

DatagramServer.java - A Datagram Server Application

DatagraClient.java - A Datagram Client Application

DOM (Document Object Model) - API for XML Files

DOMParser.java - Parsing XML Files with DOM

DOMBrowser.java - Browsing DOM Tree Structure

DOMNewDoc.java - Building a New DOM Document

DOMToXML.java - Converting DOM Documents to XML Files

SAX (Simple API for XML)

SAX (Simple API for XML) Implementation in JDK

SAX Content Handler Interface

SAXBrowser.java - SAX Based XML Browser

DTD (Document Type Definition) - XML Validation

DOMValidator.java - XML DTD Validation with DOM

Testing DOM XML DTD Validator

SAXValidator.java - XML DTD Validation with SAX

XSD (XML Schema Definition) - XML Validation

XSL (Extensible Stylesheet Language)

XSL (Extensible Stylesheet Language) - Implementation in JDK

XSLTransformer.java - XML Transformer

Message Digest Algorithm Implementations in JDK

java.security.MessageDigest - Message Digest MD5 and SHA

JcaMessageDigest.java - Message Digest Sample Program

Comparing Message Digest Output of MD5 and SHA

Private key and Public Key Pair Generation

Private and Public Keys and Related Interfaces

KeyPair and KeyPairGenerator Classes

Key Pair Sample Program - JcaKeyPair.java

DSA Private Key and Public Key Pair Sample

RSA Private Key and Public Key Pair Sample

DiffieHellman Private Key and Public Key Pair Sample

PKCS#8/X.509 Private/Public Encoding Standards

What Is Key Encoding?

PKCS#8 and X.509 Key Encoding Classes

java.security.KeyFactory - Reading Encoded Keys

JcaKeyFactoryTest.java - Key Factory Test Program

Reading DSA Private and Public Key Files

Reading RSA Private and Public Key Files

Digital Signature Algorithm and Sample Program

"keytool" Commands and "keystore" Files

Certificates and Certificate Chains

What Is "keystore"?

"keytool" - Key and Certificate Management Tool

"keytool -genkey" - Generating Keys and Self-Signed Certificates

"keytool -export/import" - Exporting and Importing Certificates

"keytool -keyclone" - Cloning Certificates with New Identities

KeyStore and Certificate Classes

java.security.cert.Certificate - The Certificate Class

Using CertificateFactory Class to Read in Certificates

Reading and Writing Certificates in DER and RFC Formats

java.security.KeyStore - The 'keystore' Class

JcaKeyStoreTest.java - 'keystore' Class Test Program

Secret Key Generation and Management

javax.crypto.SecretKey - The Secret Key Interface

javax.crypto.KeyGenerator - Generating Secret Keys

Converting Secret Keys to and from Byte Arrays

JceSecretKeyTest.java - Secret Key Test Program

Cipher - Encryption and Decryption

The SSL (Secure Socket Layer) Protocol

What Is SSL (Secure Socket Layer)?

SSL Specification Overview

JSSE - Java Implementation of SSL and TLS

SslSocketTest.java - Default SSL Socket Factory Test

SslContextTest.java - javax.net.ssl.SSLContext Class Test

Initializing SSLContext with PKCS12 File

SSL Socket Communication Testing Programs

SSL Client Authentication

HTTPS (Hypertext Transfer Protocol Secure)

What Is HTTPS?

HttpsHello.java - HTTPS Server Test Program

HttpsClient.java - HTTPS Client Test Program

HttpsClient.java Failed with JDK 1.8

Using SO_LINGER Socket Option

Connecting to HttpsHello.java with IE

HttpsEchoer.java - A Better HTTPS Server

Outdated Tutorials

Outdated: Downloading/Installing JDK 1.8.0 on Windows

Outdated: Downloading/Installing JDK 1.7.0 on Windows

Outdated: Downloading/Installing JDK 1.6.2 on Windows

Outdated: Downloading and Installing JDK 1.5.0 on Windows

Outdated: Downloading and Installing JDK 1.4.1 on Windows

Outdated: Downloading and Installing JDK 1.3.1 on Windows

References

Full Version in PDF/EPUB

Keywords: Java, JDK, Tutorial, Examples