+353-1-416-8900REST OF WORLD
+44-20-3973-8888REST OF WORLD
1-917-300-0470EAST COAST U.S
1-800-526-8630U.S. (TOLL FREE)

Practical Java Programming for IoT, AI, and Blockchain. Edition No. 1

  • Book

  • 480 Pages
  • August 2019
  • John Wiley and Sons Ltd
  • ID: 5839904

Learn practical uses for some of the hottest tech applications trending among technology professionals 

We are living in an era of digital revolution. On the horizon, many emerging digital technologies are being developed at a breathtaking speed. Whether we like it or not, whether we are ready or not, digital technologies are going to penetrate more and more, deeper and deeper, into every aspect of our lives. This is going to fundamentally change how we live, how we work, and how we socialize.

Java, as a modern high-level programming language, is an excellent tool for helping us to learn these digital technologies, as well as to develop digital applications, such as IoT, AI, Cybersecurity, Blockchain and more. Practical Java Programming uses Java as a tool to help you learn these new digital technologies and to be better prepared for the future changes.

  • Gives you a brief overview for getting started with Java Programming
  • Dives into how you can apply your new knowledge to some of the biggest trending applications today
  • Helps you understand how to program Java to interact with operating systems, networking, and mobile applications
  • Shows you how Java can be used in trending tech applications such as IoT (Internet of Things), AI (Artificial Intelligence), Cybersecurity, and Blockchain

Get ready to find out firsthand how Java can be used for connected home devices, healthcare, the cloud, and all the hottest tech applications. 

Table of Contents

Preface xix

Introduction xxi

Part I 1

Chapter 1 Introduction to Java 3

1.1 What is Java? 3

1.2 Versions of Java 5

1.3 Java Architecture 7

1.4 Editions of Java 8

1.5 The Java Spring Framework 9

1.6 Advantages and Disadvantages of Java 10

1.6.1 Advantages 10

1.6.2 Disadvantages 11

1.7 Java Certification 11

1.8 Summary 12

1.9 Chapter Review Questions 12

Chapter 2 Getting Started with Java Programming 13

2.1 Downloading and Installing Java 13

2.2 Java IDEs 17

2.3 Java Hello World Program 20

2.4 Java Online Compilers 25

2.5 Java Online Code Converters 31

2.6 Java Free Online Courses and Tutorials 31

2.7 Java Version Control 36

2.8 Summary 37

2.9 Chapter Review Questions 38

Part II 39

Chapter 3 Basic Java Programming 41

3.1 Introduction 42

3.2 Variables 42

3.2.1 Constants 44

3.2.2 The String and StringBuffer Types 45

3.2.3 The VAR Variable Type 46

3.3 Operators 47

3.4 Reserved Words 48

3.5 Input and Output 48

3.6 Loops and Selections 51

3.7 Arrays, Matrices, and ArrayLists 54

3.8 Reading and Writing Files 58

3.9 Methods 60

3.10 Object-Oriented Programming 62

3.10.1 Classes and Objects 62

3.10.2 Instantiation 63

3.10.3 Encapsulation 63

3.10.4 Inheritance 63

3.10.5 Overriding and Overloading 63

3.10.6 Polymorphism 63

3.10.7 Object Accessibility 64

3.10.8 Anonymous Inner Classes 64

3.11 Multithreading 68

3.11.1 The Life Cycle of a Thread 73

3.11.2 Thread Priorities 76

3.11.3 Thread Scheduling 76

3.11.4 Thread Synchronization 77

3.12 Date, Time, Timer, and Sleep Methods 78

3.13 Executing System Commands 83

3.14 Packages and Programming on a Large Scale 86

3.15 Software Engineering 88

3.15.1 The Software Development Cycle 89

3.15.2 Indentation 90

3.15.3 Comments 91

3.15.4 Naming Conventions 92

3.16 Deploying Java Applications 93

3.16.1 Using a Windows Batch File 93

3.16.2 Using an Executable JAR File 94

3.16.3 Using Microsoft Visual Studio 95

3.16.4 Java Application Installations 96

3.17 Summary 98

3.18 Chapter Review Questions 98

Chapter 4 Java Programming for Windows Applications 99

4.1 Introduction 99

4.2 Java Swing Applications 100

4.2.1 For More Information 105

4.3 JavaFX Applications 105

4.3.1 JavaFX Window 106

4.3.2 Creating a Label and Button in JavaFX 108

4.3.3 JavaFX Charts 110

4.3.4 Handling Logins in JavaFX 112

4.3.5 Creating an Image Viewer in JavaFX 115

4.3.6 Creating a JavaFX Web Viewer 117

4.3.7 Creating a Menu in JavaFX 118

4.3.8 Creating a JavaFX File Chooser 120

4.3.9 JavaFX Tutorials 122

4.4 Deploying JavaFX Applications 125

4.5 Summary 127

4.6 Chapter Review Questions 127

Chapter 5 Java Programming for Networking Applications 129

5.1 Introduction 129

5.1.1 Local Area Network and Wide Area Network 132

5.1.2 The Cisco Three-Tier Enterprise Network Architecture 132

5.1.3 Key Network Components 133

5.1.4 Traditional Networks vs. Software-Defined Networking 134

5.2 Java Network Information Programming 136

5.3 Java Socket Programming 143

5.3.1 Java UDP Client-Server Programming 143

5.3.2 Java TCP Client-Server Programming 146

5.3.3 Java Multithreaded EchoServer Programming 148

5.4 Java HTTP Programming 151

5.4.1 A Java HTTP/HTTPS Client 151

5.4.2 A Java HTTP Server 158

5.4.3 Java Multithreaded HTTP Server 159

5.5 Java Email SMTP Programming 164

5.6 Java RMI Client-Server Programming 168

5.7 Getting Started with SDN 172

5.7.1 Getting Started with OpenFlow 172

5.7.2 Getting Started with Floodlight 181

5.7.3 Getting Started with OpenDaylight 181

5.8 Java Network Programming Resources 181

5.9 Summary 182

5.10 Chapter Review Questions 182

Chapter 6 Java Programming for Mobile Applications 183

6.1 Introduction 183

6.2 Android Studio 184

6.3 The Hello World App 186

6.4 The Button and TextView Apps 192

6.5 The Sensor App 196

6.6 Deploying Android Apps 200

6.7 The Activity Life Cycle of an Android App 202

6.8 MIT App Inventor 204

Speech Recognition App 204

Translation App 208

6.9 5G 213

6.9.1 Millimeter Waves 217

6.9.2 Small Cells 217

6.9.3 Massive MIMO 217

6.9.4 Beamforming 218

6.9.5 Full Duplex 218

6.9.6 Future 6G and 7G 218

6.10 Summary 219

6.11 Chapter Review Questions 219

Part III 221

Chapter 7 Java Programming for IoT Applications 223

7.1 What is the Internet of Things? 223

7.2 IoT Communication Protocols 227

7.2.1 MQTT 228

7.2.2 CoAP 229

7.2.3 XMPP 229

7.2.4 SOAP 229

7.2.5 REST 229

7.3 IoT Platforms 230

7.4 IoT Security 230

7.5 Why Java? 230

7.6 Java IoT with Raspberry Pi 231

7.6.1 Raspberry Pi Setup 232

7.6.2 Java GPIO Examples 237

7.6.3 Running Python Programs from Java 244

7.6.4 Java PWM Example 246

7.6.5 Java PIR and LED Example 248

7.6.6 Java I2C Example 251

7.6.7 Java ADC Examples 255

7.6.8 Java Digital Sensor Examples 259

7.6.9 Java MQTT Example 263

7.6.10 Java REST Example 266

7.7 An Oracle Java ME Embedded Client 270

7.8 Other Java IoT Uses 271

7.8.1 Eclipse Open IoT Stack for Java 271

7.8.2 IBM Watson IoT for Java 271

7.8.3 Amazon IoT for Java 272

7.8.4 Microsoft Azure IoT for Java 272

7.9 Summary 273

7.10 Chapter Review Questions 273

Chapter 8 Java Programming for AI Applications 275

8.1 What is Artificial Intelligence? 275

8.1.1 History of AI 277

8.1.2 Cloud AI vs. Edge AI 279

8.2 Neural Networks 280

8.2.1 The Perceptron 280

8.2.2 MultiLayered Perceptron/Backpropagation/Feedforward 284

8.3 Machine Learning 286

8.4 Deep Learning 288

8.5 Java AI Libraries 292

8.6 Java Examples for Neural Networks 293

8.6.1 Java Perceptron Example 293

8.6.2 Java Neural Network Backpropagation Example 296

8.7 Java Examples for Machine Learning 300

8.8 Java Examples for Deep Learning 303

8.9 TensorFlow for Java 309

8.10 AI Resources 313

8.11 Summary 313

8.12 Chapter Review Questions 314

Chapter 9 Java Programming for Cybersecurity Applications 315

9.1 What is Cybersecurity? 315

9.2 What is Encryption? 316

9.2.1 Private Key Encryption 317

9.2.2 Public Key Encryption 319

9.3 Hash Functions and Message Digests 321

9.4 Digital Signatures 323

9.5 Digital Certificates 325

9.6 Case Study 1: Secure Email 327

9.7 Case Study 2: Secure Web 328

9.8 Java Private Key Encryption Example 329

9.9 Java Public Key Encryption Example 330

9.10 Java Digital Signature/Message Digest Example 332

9.11 Java Digital Certificate Example 338

9.12 Other Java Examples 342

9.13 Summary 345

9.14 Chapter Review Questions 346

Chapter 10 Java Programming for Blockchain Applications 347

10.1 What is Blockchain? 347

10.2 How Do You Validate a Blockchain? 349

10.3 How Do You Mine the Blocks? 350

10.4 How Does Blockchain Work? 350

10.5 Uses of Blockchain 352

10.5.1 Bitcoin 353

10.5.2 Smart Contracts 358

10.5.3 Healthcare 358

10.5.4 Manufacture and Supply Chains 359

10.5.5 Internet of Things 359

10.5.6 Government 360

10.6 Issues with Blockchain 360

10.7 Java Blockchain Examples 361

10.8 Java Blockchain Transaction Examples 367

10.9 Java BitcoinJ Example 373

10.9.1 The Testnet 375

10.10 Java Web3j Examples 375

10.11 Java EthereumJ Examples 378

10.12 Java Ethereum Smart Contract Example 380

10.13 Go Further: Choosing a Blockchain Platform 386

10.14 Summary 387

10.15 Chapter Review Questions 388

Chapter 11 Java Programming for Big Data Applications 389

11.1 What is Big Data? 389

11.2 Sources of Big Data 390

11.3 The Three Vs of Big Data 391

11.4 Benefits of Big Data 392

11.5 What is Hadoop? 392

11.6 Key Components of Hadoop 393

11.6.1 HDFS 393

11.6.2 MapReduce 394

11.6.3 Hadoop Common 395

11.6.4 Hadoop YARN 395

11.6.5 Overview of a Hadoop Cluster 395

11.7 Implementing Hadoop on a Raspberry Pi Cluster 396

11.7.1 Raspberry Pi Installation and Configuration 397

11.7.2 Hadoop Installation and Configuration 397

Prepare the Hadoop User Account and Group 398

Configure SSH 398

Download and Install Hadoop 398

Configure Environment Variables 399

Configure Hadoop 399

Start and Stop Hadoop Services 401

Test Hadoop 401

Hadoop on a Web Browser 403

11.8 Java Hadoop Example 406

11.9 Summary 412

11.10 Chapter Review Questions 412

Appendix A Java Documentation and Archiving Tools and Online Resources 413

Javadoc Tutorial 413

JAR Tutorial 418

Useful Java Resources 420

Appendix B Apache Maven Tutorial 423

Downloading Maven 423

Creating a Maven Project 424

Compiling and Building the Maven Project 428

Running the Maven Project 428

Appendix C Git and GitHub Tutorial 431

Terms and Definitions 440

Cheat Sheet 442

Index 445

Authors

Perry Xiao