APCS – Unit 2 – Lab 2.1. Download and Install JDK and Eclipse for Java Developers

The Java Development Kit (JDK), officially named “Java Platform Standard Edition” or “Java SE“, is needed for writing Java programs. In this lab activity, please follow the instructions to download and install JDK and Eclipse IDE on your personal PC or laptop.

If you have a Mac OS, please go directly to part 2 of the document.

Part 1. For Windows PCs and Laptops Only

Step 1. Determine if you have a 32 – bit or 64- bit computer

First of all, you will need to determine if you have a 32-bit or 64-bit computer or laptop. Here’s a website with detailed instructions https://www.computerhope.com/issues/ch001121.htm.

Step 2. Download Java SE Development Kit 8 (JDK 8)

Go to the Oracle Java website https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html, scroll down to the session named “Java SE Development Kit 8u261”, find the product / file description that matches your computer’s operating system and CPU type, and download the installer file.

Step 3. Install JDK

Run the downloaded installer (e.g., “jdk-8u261-windows-x64.exe“), which installs both the JDK and JRE.

If you have an Windows operating system, by default, JDK is installed in directory “C:Program FilesJavajdk-1.8.0.{x}“, where {x} denotes the update number. Accept the defaults and follow the screen instructions to install JDK. Use your “File Explorer”, navigate to "C:Program FilesJava" to inspect the sub-directories. Take note of your JDK installed directory jdk-1.8.0.{x}, in particular, the update number {x}, which you will need in the next step. 

Step 4. Include JDK’s “bin” Directory in the PATH

Windows’ Command Prompt (CMD) searches the current directory and the directories listed in the PATH environment variable (or system variable) for executable programs. JDK’s programs (such as Java compiler "javac.exe” and Java runtime "java.exe“) reside in the sub-directory “bin” of the JDK installed directory. You need to include JDK’s “bin” in the PATH to run the JDK programs.

To edit the PATH environment variable in Windows 10:

  1. Launch “Control Panel” ⇒ (Optional) “System and Security” ⇒ “System” ⇒ Click “Advanced system settings” on the left pane.
  2. Switch to “Advanced” tab ⇒ Click “Environment Variables” button.
  3. Under “System Variables” (the bottom pane), scroll down to select variable “Path” ⇒ Click “Edit…”.
  4. For Newer Windows 10:
    You shall see a TABLE listing all the existing PATH entries (if not, goto next step). Click “New” ⇒ Click “Browse” and navigate to your JDK’s “bin” directory, i.e., “c:Program FilesJavajdk-1.8.0.{x}bin“, where {x} is your installation update number ⇒ Select “Move Up” to move this entry all the way to the TOP.
  5. For Older Windows 10 (Time to change your computer!):
    (CAUTION: Read this paragraph 3 times before doing this step! Don’t push “Apply” or “OK” until you are 101% sure. There is no UNDO!!!)
    (To be SAFE, copy the content of the “Variable value” to Notepad before changing it!!!)
    In “Variable value” field, APPEND “c:Program FilesJavajdk-1.8.0.{x}bin” (where {x} is your installation update number) IN FRONT of all the existing directories, followed by a semi-colon (;) to separate the JDK’s bin directory from the rest of the existing directories. DO NOT DELETE any existing entries; otherwise, some existing applications may not run.
    Variable name  : PATH
    Variable value : c:Program FilesJavajdk-1.8.0.{x}bin;[do not delete exiting entries...]

Note: If you have started CMD, you need to re-start for the new environment settings to take effect.

Step 5. Verify and test your JDK installation

Launch a CMD via one of the following means:

  1. Click “Search” button ⇒ Type “cmd” ⇒ Choose “Command Prompt”, or
  2. Right-click “Start” button ⇒ run… ⇒ enter “cmd”, or
  3. Click “Start” button ⇒ Windows System ⇒ Command Prompt

Issue the following commands to verify your JDK installation:

  1. Issue “path” command to list the contents of the PATH environment variable. Check to make sure that your JDK’s “bin” is listed in the PATH.
    path
    PATH=c:Program FilesJavajdk-13.0.{x}bin;other entries...
  2. Issue the following commands to verify that JDK/JRE are properly installed and display their version:
    // Display the JDK version
    javac -version
    javac 1.8.0_{x}
    // Display the JRE version
    java -version
    java version "1.8.0_{x}" 2019-10-15
    Java(TM) SE Runtime Environment (build 13.0.1+9)
    Java HotSpot(TM) 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing)

Example:

Step 6. Download and Install Eclipse IDE for Java Developer

There are multiple versions of Eclipse. For an example, if you want to build server based enterprise applications, you might want to choose the Eclipse IDE for Java EE Developer. In our course, we will use the Eclipse IDE for Java Developers, and you can download the package here at: https://www.eclipse.org/downloads/packages/

Under the “Download Links”, choose the file description / name that matches your operating system and processor, and click on the link to download.

To install Eclipse, simply unzip the downloaded file into a directory of your choice (e.g., “c:Program FilesEclipse“).

I prefer the zip version, because there is no need to run any installer. Moreover, you can simply delete the entire Eclipse directory when it is no longer needed (without running any un-installer). You are free to move or rename the directory. You can install (unzip) multiple copies of Eclipse in the same machine.

Part 2. For Mac PCs and Laptops Only

Step 1. Determine if you have a 32 – bit or 64- bit CPU

First of all, you will need to determine if you have a 32-bit or 64-bit CPU. Most likely, you have a 64 – bit but we need to be sure. Here’s a website with detailed instructions, and scroll to the very end of the web page, and you can find the instructions for Mac: https://www.computerhope.com/issues/ch001121.htm.

Step 2. Download Java SE Development Kit 8 (JDK 8)

Go to the Oracle Java website https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html, scroll down to the session named “Java SE Development Kit 8u261”, find the product / file description that matches your computer’s operating system and CPU type, and download the installer file.

Step 3: Install JDK/JRE
  1. Double-click the downloaded Disk Image (DMG) file. Follow the screen instructions to install JDK/JRE.
  2. Eject the DMG file.
  3. To verify your installation, open a “Terminal” and issue these commands.
    // Display the JDK version
    javac -version
    javac 1.8.0.{x}
    // Display the JRE version
    java -version
    java version "1.8.0.{x}"
    ......
    // Display the location of Java Compiler
    which javac
    /usr/bin/javac
    // Display the location of Java Runtime
    which java
    /usr/bin/java
Step 4. Download and Install Eclipse IDE for Java Developer

There are multiple versions of Eclipse. For an example, if you want to build server based enterprise applications, you might want to choose the Eclipse IDE for Java EE Developer. In our course, we will use the Eclipse IDE for Java Developers, and you can download the package here at: https://www.eclipse.org/downloads/packages/release/kepler/sr1/eclipse-ide-java-developers.

Under the “Download Links”, choose the file description / name that matches your operating system and processor, and click on the link to download the Disk Image (DMG) file. Follow the screen instructions to install Eclipse. Eclipse will be installed under “/Applications/eclipse“.

Citations, Sources and References:
  • https://www3.ntu.edu.sg/home/ehchua/programming/howto/JDK_Howto.html
  • Oracle Java documentation
  • Eclipse for Java documentatio