JDK Tutorials - Herong's Tutorial Examples


Copyright © 2017 by Dr. Herong Yang. All rights reserved.

JDK Tutorials This free book is a collection of tutorial notes and sample codes written by the author while he was learning JDK (Java Development Kit) himself. Topics include Blowfish, Calendar, certificate, character set, cipher, client authentication, collections, datagram, Date, decryption, DES, digital signature, encryption, DOM, DTD, HTTP, J2SDK, Java, JCA, JDK, keytool, Locale, MD5, public key, RSA, socket, SSL, package, Unicode, UTF-8, XML.

Table of Contents

About This JDK Tutorial Book

Downloading and Installing JDK 1.8.0 on Windows

Downloading and Installing JDK 1.7.0 on Windows

Downloading and Installing JDK 1.6.2 on Windows

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

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

XML XSD Schema Validation

XML XSD Schema Validation Test Result

XML XSD Schema Validation with Xerces

XSD Validation Failed with SAXParserFactory

XSD Schema Validator on XML SAX Object

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

What Is Digital Signature?

The Signing Process and the Verification Process

java.security.Signature - The Data Signing Class

JcaSignatureTest.java - Signature Test Program

Signature Test Program Result

JcaSign.java - Signature Generation Sample Program

JcaVerify.java - Signature Verification 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 - Secret Key Encryption and Decryption

javax.crypto.Cipher - The Secret Key Encryption Class

JceSecretCipher.java - Secret Key Encryption Sample Program

Blowfish and DES Secret Key Encryption Tests

JcePublicCipher.java - Private and Public Key Encryption

DSA Public Key Encryption Tests

RSA Public Key Encryption Tests

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

SSL Socket Communication Testing Programs

SSL Socket Communication Test

SslReverseEchoer.java - SSL Server Socket Example

SslSocketClient.java - SSL Client Socket Example

Making Self-Signed Certificates Trusted

javax.net.debug - Debugging SSL Socket Communication

SSL Client Authentication

What Is SSL Client Authentication?

Preparing Certificates for Client Authentication

Test Server Program for Client Authentication

Test Client Program for Client Authentication

SSL Client Authentication Test Result

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 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


PDF Printing Version

Keywords: Java, JDK, Tutorial, Examples