Transitioning to Java

Book description

Develop your Java coding skills by exploring object-oriented methodologies, functional programming, software design patterns, and more Purchase of the print or Kindle book includes a free PDF eBook

Key Features

  • Get started with programming in Java with this step-by-step guide for experienced programmers
  • Re-enforce your knowledge of object-oriented methodologies applied in Java
  • Develop the range of skills necessary for you to become a successful Java developer

Book Description

This comprehensive guide will help non-Java developers already using different languages transition from their current language to all things Java. The chapters are designed in a way that re-enforces a developer’s existing knowledge of object-oriented methodologies as they apply to Java.

This book has been divided into four sections, with each section touching upon different aspects that’ll enable your effective transition. The first section helps you get to grips with the Java development environment and the Maven build tool for modern Java applications. In the second section, you’ll learn about Java language fundamentals, along with exploring object-oriented programming (OOP) methodologies and functional programming and discovering how to implement software design patterns in Java. The third section shows you how to code in Java on different platforms and helps you get familiar with the challenges faced on these platforms. In the fourth section, you’ll find out how you can manage and package your Java code.

By the end of this Java programming book, you’ll have learned the core concepts of Java that’ll help you successfully transition from a different language to Java.

What you will learn

  • Gain a solid understanding of the syntax in Java
  • Explore the object-oriented programming basics of the Java language
  • Discover how to implement functions in Java
  • Understand which Java frameworks would be best for solving various problems
  • Explore creational, structural, and behavioral patterns in Java
  • Get to grips with server-side coding in Java

Who this book is for

This book is for anyone who is currently working with other programming languages and wishes to add Java to their skillset. Prior working experience as a developer using languages other than Java is expected, although no prior knowledge of Java is required.

Table of contents

  1. Transitioning to Java
  2. Foreword
  3. Contributors
  4. About the author
  5. About the reviewers
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
    9. Download a free PDF copy of this book
  7. Part 1:The Java Development Environment
  8. Chapter 1: Understanding Java Distributions
    1. Technical requirements
    2. A little history
    3. What makes Java special?
    4. Why are there many distributions of Java?
    5. Which Java should you get?
      1. How is Java licensed?
    6. Why are there so many versions of Java?
    7. Installing Java
      1. As an admin
      2. As a non-admin
    8. What is in the box?
      1. Compiling and executing a Java program
      2. Assembling and packaging a Java application
      3. Documenting Java classes
      4. REPL
    9. Summary
    10. Further reading
  9. Chapter 2: Code, Compile, and Execute
    1. Technical requirements
    2. The first program
    3. JShell – REPL in Java
    4. The two-step compile and execute process – javac and java/javaw
    5. Launch Single-File Source-Code Programs
      1. For Windows, macOS, and Linux
      2. For macOS and Linux – Shebang files
    6. Integrated development environments
      1. Eclipse Foundation – Eclipse
      2. Apache NetBeans
      3. Microsoft Visual Studio Code
      4. JetBrains IntelliJ IDEA
      5. Which IDE should you use?
    7. Summary
    8. Further reading
  10. Chapter 3: The Maven Build Tool
    1. Technical requirements
    2. Installing Maven
      1. Windows
      2. Linux
      3. macOS
    3. Overview of Maven functionality
      1. Dependency management
      2. Maven plugins
      3. Maven project layout
      4. Java source code packages
    4. The pom.xml configuration file
      1. jar – Java archive
      2. war – web archive
      3. ear – enterprise archive
      4. pom – POM
      5. The build section
    5. Running Maven
      1. Command-line Maven
      2. Running Maven in an IDE
    6. Summary
    7. Further reading
  11. Part 2:Language Fundamentals
  12. Chapter 4: Language Fundamentals – Data Types and Variables
    1. Technical requirements
    2. Primitive data types
      1. Type safety
      2. Literal values
      3. Integers
      4. Floating point
      5. Boolean
      6. char
    3. A special case – String
    4. Naming identifiers
      1. Constants
      2. Operators
      3. Casting
      4. Overflow and underflow
      5. Wrapper classes
      6. The math library
    5. Summary
    6. Further reading
  13. Chapter 5: Language Fundamentals – Classes
    1. Technical requirements
    2. Class fields
    3. Understanding access control
      1. Packages
      2. The public specifier
      3. The private specifier
      4. The protected specifier
      5. The package specifier
    4. Understanding classes
      1. constructor and finalize methods
      2. Revising the compound interest program
      3. Class organization based on functionality
    5. Summary
    6. Further reading
  14. Chapter 6: Methods, Interfaces, Records, and Their Relationships
    1. Technical requirements
    2. Understanding methods
      1. Access control designation
      2. Static or non-static designation and the this reference
      3. Override permission – final
      4. Override required – abstract
      5. Return type
      6. Method name
      7. Parameter variables
      8. Annotations
      9. Exception handling – throws
      10. Thread setting
      11. Generic parameters
    3. Understanding inheritance
      1. The superclass of all objects, the Object class
    4. Understanding the class interface
      1. Abstract class versus interface
      2. Sealed classes and interfaces
    5. Understanding the record class
    6. Understanding polymorphism
    7. Understanding composition in classes
      1. Association
      2. Aggregation
    8. Summary
  15. Chapter 7: Java Syntax and Exceptions
    1. Technical requirements
    2. Understanding coding structures
      1. Code blocks
      2. Statements
      3. Expressions
      4. Operators
      5. Iteration
      6. Decision-making
    3. Handling exceptions
      1. The stack trace
      2. Ending the program
      3. The throw and throws statements
      4. The finally block
      5. Creating your own exception classes
    4. Summary
    5. Further reading
  16. Chapter 8: Arrays, Collections, Generics, Functions, and Streams
    1. Technical requirements
    2. Understanding the array data structure
    3. Understanding the Collections Framework
    4. Using sequential implementations and interfaces
      1. ArrayList
      2. LinkedList
      3. ArrayDeque
      4. The Collection interface
      5. How to declare a collection
    5. Understanding Generics in the Collections Framework
    6. Using sequential implementations and interfaces with Generics
    7. Understanding Collections Framework map structures
      1. HashMap
      2. LinkedHashMap
      3. TreeMap
    8. Understanding functions in Java
    9. Using streams in collections
    10. Summary
    11. Further reading
  17. Chapter 9: Using Threads in Java
    1. Technical requirements
    2. Creating Java native OS threads
      1. Extending the Thread class
      2. Implementing the Runnable interface
      3. Creating a thread pool with ExecutorService
      4. Implementing the Callable interface
      5. Managing threads
      6. Daemon and non-daemon threads
      7. Thread priority
    3. Preventing race and deadlock conditions in threads
      1. Race condition
      2. Deadlock condition
    4. Creating new virtual threads
    5. Summary
    6. Further reading
  18. Chapter 10: Implementing Software Design Principles and Patterns in Java
    1. Technical requirements
    2. SOLID software design principles
      1. S – Separation of concerns/single responsibility
      2. O – Open/closed
      3. L – Liskov substitution
      4. I – Interface segregation
      5. D – Dependency inversion
    3. Software design patterns
      1. Singleton
      2. Factory
      3. Adapter
      4. Observer
    4. Summary
    5. Further reading
  19. Chapter 11: Documentation and Logging
    1. Technical requirements
    2. Creating documentation
      1. Comments
      2. Javadocs
    3. Using logging
      1. java.util.logging
      2. Log4j2
    4. Summary
    5. Further reading
  20. Chapter 12: BigDecimal and Unit Testing
    1. Technical requirements
    2. Using BigDecimal
    3. What is JUnit 5?
    4. Testing with JUnit 5
    5. Performing parameterized testing
    6. Summary
    7. Further reading
  21. Part 3:GUI and Web Coding in Java
  22. Chapter 13: Desktop Graphical User Interface Coding with Swing and JavaFX
    1. Technical requirements
    2. A brief history of Java GUIs
    3. Financial calculator program design
      1. Internationalization – i18n
    4. Using the Swing GUI framework
      1. JFrame
      2. JPanel
      3. Event handlers
      4. Document filter
      5. Pattern matching with regular expressions
      6. Controls and panels
    5. Using the JavaFX GUI framework
      1. Application
      2. PrimaryStage
      3. Pane
      4. Scene
      5. CSS style sheets
      6. JavaFX bean
      7. BigDecimalTextField
      8. Controls
      9. Binding
    6. Summary
    7. Further reading
  23. Chapter 14: Server-Side Coding with Jakarta
    1. Technical requirements
    2. Understanding the role of the Java application server
      1. GlassFish 7.0
    3. Configuring a web project with Maven
      1. Changes to the pom.xml file
    4. Understanding what a servlet does and how it is coded
      1. What happens when a servlet is requested?
      2. How does a servlet access the query string in a request?
      3. How does a servlet remember my data?
    5. Configuring deployment with the web.xml file
    6. Summary
    7. Further reading
  24. Chapter 15: Jakarta Faces Application
    1. Technical requirements
    2. Configuring a Faces application
    3. Creating an object managed by Context Dependency Injection and validated with Bean Validation
      1. FinanceBean
      2. Scopes
      3. Calculations
    4. Using XHTML, Facelets, and Expression Language for rendering pages
      1. Deploying a Faces web application
    5. Understanding the life cycle of a Faces page
    6. Summary
    7. Further reading
  25. Part 4:Packaging Java Code
  26. Chapter 16: Deploying Java in Standalone Packages and Containers
    1. Technical requirements
    2. Exploring what modular Java is
    3. Creating a custom JRE with jlink
    4. Packaging with an installer using jpackage
    5. Using the Docker container system
    6. Working with Docker images
    7. Creating a Docker image
    8. Publishing an image
    9. Summary
    10. Further reading
  27. Index
    1. Why subscribe?
  28. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts
    3. Download a free PDF copy of this book

Product information

  • Title: Transitioning to Java
  • Author(s): Ken Fogel
  • Release date: April 2023
  • Publisher(s): Packt Publishing
  • ISBN: 9781804614013