Learn Labs
15. Appendices A & B

15.2 A.1 Windows

Two options as of Windows 10 — and the book is unambiguous about which to prefer:

Two options as of Windows 10 — and the book is unambiguous about which to prefer:

Option 1 (preferred): Windows Subsystem for Linux (WSL)

"you can install native Ubuntu support under Windows using Windows Subsystem for Linux (WSL). At the time of publication, Microsoft still considers WSL to be an EXPERIMENTAL feature. Though it acts similar to a virtual machine, it DOES NOT REQUIRE THE RESOURCES OF A FULL VM and provides RICHER INTEGRATION with the Windows OS."

"The latter method is HIGHLY PREFERRED because it provides A MUCH SIMPLER SETUP THAT MORE CLOSELY MATCHES THE TYPICAL PRODUCTION ENVIRONMENT."

# after installing WSL per Microsoft's "What Is the Windows Subsystem for
# Linux?" page, and installing the Ubuntu system package:
sudo apt install openjdk-16-jre-headless

"Once you have installed the JDK, you can proceed to install Apache Kafka using the instructions in Chapter 2." — i.e. from here it is just Linux.

Option 2: native Java on Windows

⚠️ "For older versions of Windows, or if you prefer not to use WSL... BE AWARE, HOWEVER, THAT THIS CAN INTRODUCE BUGS SPECIFIC TO THE WINDOWS ENVIRONMENT. THESE BUGS MAY NOT GET THE ATTENTION IN THE APACHE KAFKA DEVELOPMENT COMMUNITY AS SIMILAR PROBLEMS ON LINUX MIGHT."

Step 1 — Java. "install the latest version of Oracle Java 16... Download a FULL JDK package so that you have all the Java tools available."

⚠️ BE CAREFUL WITH PATHS

*"it is HIGHLY RECOMMENDED that you stick to installation paths that DO NOT CONTAIN SPACES. While Windows ALLOWS spaces in paths, APPLICATIONS THAT ARE DESIGNED TO RUN IN UNIX ENVIRONMENTS ARE NOT SET UP THIS WAY, and specifying paths will be difficult.

For example, if installing JDK 16.0.1, a good choice would be C:\Java\jdk-16.0.1."*

Step 2 — environment variables. In Windows 10: "System and Security" → System → "Advanced system settings" → Advanced tab → "Environment Variables"

 NEW USER VARIABLE:   JAVA_HOME = <the path where you installed Java>
 EDIT SYSTEM Path:    add an entry  %JAVA_HOME%\bin

Step 3 — Kafka. "The installation includes ZooKeeper, so you do not have to install it separately." At publication: 2.8.0 on Scala 2.13.0. "The downloaded file will be gzip compressed and packaged with the tar utility, so you will need to use a Windows application such as 8 Zip to uncompress it." Example target: C:\kafka_2.13-2.8.0.

Step 4 — running it. ⚠️ Two differences from Linux:

  1. “you must use the batch files designed for Windows rather than the shell scripts for other platforms” → bin\windows\*.bat
  2. “These batch files also do not support backgrounding the application, so you will need a separate shell for each application.”
# SHELL 1 — ZooKeeper
PS C:\> cd kafka_2.13-2.8.0
PS C:\kafka_2.13-2.8.0> bin\windows\zookeeper-server-start.bat `
    C:\kafka_2.13-2.8.0\config\zookeeper.properties
# ... INFO PrepRequestProcessor (sid:0) started, reconfigEnabled=false

# SHELL 2 — Kafka
PS C:\> cd kafka_2.13-2.8.0
PS C:\kafka_2.13-2.8.0> .\bin\windows\kafka-server-start.bat `
    C:\kafka_2.13-2.8.0\config\server.properties
# ... INFO [KafkaServer id=0] started (kafka.server.KafkaServer)

(Note the last log line in the book's output: Recorded new controller, from now on will use broker ... — that's Ch. 6's controller registration, visible at startup.)


On this page