Book Image

OpenJDK Cookbook

Book Image

OpenJDK Cookbook

Overview of this book

Table of Contents (20 chapters)
OpenJDK Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Configuring OpenJDK on Windows


Although the initial configuration is sufficient for most tasks, it may still be required to do some configuration. In the case of OpenJDK, this is performed by setting system variables. Here we will touch only on the case that often occurs when JDK is unpacked manually—how to set it as default.

Getting ready

To follow this recipe, we will need an OpenJDK instance installed on our Windows system. Windows 7 or Windows 8 will be best, because Windows XP is already officially discontinued by Microsoft.

How to do it...

At first, we need to install our OpenJDK implementation as the default Java instance. This is often necessary for development:

  1. In order to do so, we will go to Start | Control Panel | System | Advanced | Environment Variables | User Variables (or System Variables for system-wide configuration) and add the path to the Java executable to the PATH system variable, as shown:

    Tip

    If there are other paths to other Java executables, we may need to delete them as well, but it will be better to remember them, since we may need to restore our old default Java settings.

  2. If we were installing OpenJDK from unofficial builds, there may be no need to change the PATH variable at all.

  3. To validate our newly configured variable, we will go to the Command Prompt and type the following:

    java -version
  4. The expected output is the version of our newly installed build.

How it works…

In order to set a newly installed OpenJDK instance as the default JDK, we need to change the system variable. After that change, our Java executables will be visible to the system.

There's more...

The same procedure is followed to set the CLASSPATH variable. It is not very necessary, and if you are using other libraries such as GNU classpath, you probably know about it.