Introduction to JVM Languages
上QQ阅读APP看书,第一时间看更新

Installing JDK on Windows

For Windows, JDK is available in both 32-bit and 64-bit versions. Simply run the downloaded executable file and follow the prompts. Copy and paste the path where you'll install JDK; you'll need the path after installing it.

Using the default settings, install JRE, which is part of the installation of JDK. It is strongly recommended that you keep the JRE and JDK versions in sync, so it's always best to install JRE directly from the JDK installer. Oracle states that JDK is always installed at the system-wide level; therefore, it will be available to all users.

After the installation, you'll need to add or alter some environment variables. We will show how to do this for Windows 10. For other recent versions of Windows, it should be a familiar procedure:

  1. Right-click on your Windows Start menu and select System. On the left-hand side of the window that appears, click on Advanced system settings.
  2. The System Properties window appears. Click on the Environment Variables... button. The Environment Variables window appears:
  1. Look at the System variables section at the bottom of the window. Check whether you see the JAVA_HOME variable. If not, click on the New... button; otherwise, edit the existing JAVA_HOME entry.
  2. Enter JAVA_HOME as the variable name and the full path to the root of JDK's installation directory as the value. Then click on OK to close the window.
  3. Now find the existing Path variable and add the full path to the bin subdirectory of the JDK installation directory. Keep in mind that the directories are separated by the ; character.

To verify the installation, do the following:

  1. Open a new Command Prompt (for example, by clicking on the Start menu, typing cmd, and pressing Enter)
  2. Enter javac -version and press Enter

You should see the version number that matches the downloaded JDK. If not, double-check whether you altered the environment variables correctly and make sure you opened a new Command Prompt window instead of using a previously opened one.