Java Classroom Setup Directions

(Last updated:  July 5, 2014)

This document describes the steps to install and configure the various Java development tools used in COP-2805.  Please note that many of the install locations and settings are my personal preferences, and that installing to different locations and using different environment variable settings is certainly acceptable; whatever works best for you.  Note the setup described here conforms to Oracle (formerly Sun) recommendations for the JDK and JRE setup.

For all tools, when there is a choice I suggest using the 32-bit versions, even on a 64-bit computer.  Web browsers are mostly 32-bit today, and won't work with 64-bit JRE plug-ins.  For learning purposes, the convenience of having everything “just work” is more important than the performance and security enhancements of 64-bit software.  (That will hopefully not be the case in a few years, and then you should use the 64-bit versions.)

In our course we will explore many tools, including both the Eclipse and NetBeans IDEs.  The IDEs often include bundled versions of some tools, such as Ant, JUnit, and Maven.  While you could locate where these were previously installed with NetBeans (or Eclipse), and configure these tools to refer to those locations, these tools are small and it doesn't hurt to install the extra versions that come with the tools.  By installing the tools separately (and before any IDEs), you can access them easily from the command line and update them when updates are available, without waiting for an update from NetBeans (or Eclipse), which may cause you to have to reconfigure other tools to know about the new locations and pathnames.

One of my personal preferences is to install tools into directories without version numbers.  Then if I update some tool and put the new version into the same location, I don't have to update any environment variables or reconfigure any IDE to know about the new locations.

The order you download and install tools may not matter much, but I like to install and configure the environment variables for some tools before installing IDEs or the Glassfish Java EE server.  (There is a chance those installers will locate the tools and configure themselves to use those locations, rather than install a separate version.  Even if they don't, I find the NetBeans install isn't as current, and doesn't update properly.)

Note that these directions are tested on Windows 7.  If you wish any additional help, don't hesitate to ask!

Installation Steps - Preparation for Install

  1. Remove (uninstall) old Java versions.  Also, delete folders containing old documentation, demos, and samples.  It can be difficult to delete old Java versions on Windows after you've installed a new version.  Oracle has an old version detection and removal tool you can use after you install a new version, from the Verify Java Version web page (which you should visit after installation is complete).
  2. Create the folders C:\Java (which is where we will install the JDK), C:\Java\MyJars (which is where we can put any needed Jar files that aren't already listed on CLASSPATH), and C:\Java\glassfish4 (which is where we will install the Glassfish Java EE server).  If you don't like the name MyJars, pick another; I've also used MyExtensions and MyLibs.
  3. Run the command:
      C:\Temp>set >env.txt

    This makes a backup copy of all your environment variables, always a good idea before making changes that can prevent your system from working correctly.  Print out env.txt, just in case.

  4. An easier way to manage, view, save, and edit environment variables is to install and then use the free tool Rapid Environment Editor.  Using that or the standard Windows environment variable editor, create or edit the following environment variables and set them to where you will install the software (change the values if you plan on installing in different locations):

    It is okay if your CLASSPATH setting has an additional entry at the end.  (The Apple QuickTime installer adds one, but it isn't needed unless you want to use QuickTime from your Java applications.  Even in that case, you don't need that entry on CLASSPATH.  Just put the file in the C:\Java\MyJars\ folder, and change the QTJAVA environment variable to refer to the zip file at its new location.)  Make sure you don't forget to include the leading period!

    In order to use the Derby (“Java DB”) database, these four files from the %DERBY_HOME%\lib folder must be listed on the CLASSPATH:
       derby.jar  derbyclient.jar  derbynet.jar  derbytools.jar

    While only two files are actually needed, the ones used would depend on the mode of your database (server or embedded).  Adding all four ensures you can use the Derby database in any mode, but the simple way to include these Jars is to list db\lib\* on CLASSPATH, as shown above.

    Add these entries to the PATH environment variable:


    (Using environment variables in PATH, such as “%JAVA_HOME%\bin” instead of “C:\Java\bin”, just won't work in most cases.)  The order these are listed in PATH shouldn't matter, but it might if your system uses an older java.exe often installed by default under C:\windows\System32\.  while the Java installer should updated that, sometimes it doesn't, so list your Java paths early on PATH.

    Note that the public JRE that is installed, isn't listed on the PATH.  The reason is, the tools in the JAVA_HOME\bin folder are identical to the ones in the JRE's bin folder.  You don't need to list both locations unless you plan on installing multiple JREs.  That might happen if you need to test your code against multiple JREs, or if you leave the Java automatic updater turned on.  In that case, the public JRE you plan on using (C:\Program Files...\Java\jre8\bin) must precede the JDK's private JRE (C:\Java\bin) on PATH, or the public JRE won't be used.  In this case, remember there are configuration files in the JRE, so settings changed in one JRE won't affect other JREs.

    You can also just not install the public JRE when running the installer, but I don't recommend that.  Windows contains a registry setting used by some apps (some IDEs, web browsers, etc.) to find a JRE to use.  That is usually the public JRE installed last.  If you don't install the public JRE, that setting is unchanged and may point to an older version of Java, or a version that you've already deleted.  (This registry update is why it sometimes requires a reboot when updating Java, before the new version is used by all applications.)

    Make sure PATH doesn't already refer to any older JRE or JDK that might have been previously installed.  Note, some vendors pre-install a JRE in C:\windows (or some other location already listed on PATH).  If you think that is the case (that is, when you check the version used from the command line and it shows an old version), you must list C:\Java\bin first on PATH.

    Remember that both PATH and CLASSPATH are a list of folders (or, for CLASSPATH, folders, jar files, and zip files).  Each one is separated from the next with a semicolon (“;”) on Windows:

       FOO;BAR   — Good!
       FOO; BAR  — No good!
       FOO:BAR   — No good!

    (Unix, Linux, and Max OS use a colon (“:”) as a separator instead.)

  5. When updating the JDK and/or JRE, they go in the same locations as the previous version if you follow these guidelines.  However, the installer may not uninstall the previous version, leading to corruption if you later try to uninstall the older version.  (The most recent JDK install does offer to uninstall the previous version.)  So, as stated previously, it is best to uninstall any old JDK and JRE.  (The installer seems to handle multiple JREs better.  If you use the defaults for the JDK, a new directory is used for every version, so you don't need to uninstall first.  But then you will need to update your environment variables after each update.)  Don't forget to delete the folders you plan on replacing with new versions, including doc, samples, demos, etc.  Since these were simply extracted from a zip file, there is no uninstall option for them.

Download and Install Tools

Download the development tools and install in this order:

  1. JDK 8, 32-bit Windows version, for Java SE, the latest version.  (URL:  You should install the 32-bit version even if you have Windows x64.  The 64-bit version may not work well with some web browsers, Eclipse, or other Java-related tools.

    This installer includes several sub-installers.  The first one is for the JDK.  Change the install location to “C:\Java”, and later you can let the public JRE install in its default location).  Install everything.  (Samples and demos are currently a separate zip download, and not installed with the JDK installer.  However, samples and demos folders are deleted by the JDK installer for some reason, so always install the JDK first, then other stuff.)

    When you use Java's automatic updater for Windows, third-party software may be included.  The two additional packages delivered to users are currently the Ask Toolbar and the McAfee Security Scanner.  With Java updates (and sometimes, an install), you must specifically opt out of the additional software installations.  You may not want to use, but apparently it's installer delays its actions for 10 minutes or so, so that if you accidentally install it, you won't see the uninstall option show up in the control panel right away.

    Screen-shot of first JDK install screen

    Screen-shot of first JDK 7 install screen after changing install location

    Screen-shot of JRE 7 install screen, showing defaults selected

    After the installer finishes, you should launch the Java Control Panel and examine the settings.  I generally turn off automatic JRE updates.  Next, either set the security level to “medium” (which allows running unsigned applets from anywhere, but they still will pop-up warning dialogs), OR leave the security setting alone and add localhost to the exception list.  This is a list of sites from which you will allow unsigned or self-signed code to run.  You should add a couple of entries to enable running code from your local computer:


    Note that IPv6 isn't currently supported by this exception list; also the JRE doesn't resolve name to IP addresses, so you need both the host name as well has the IP addresses added.  Also note you will get a warning with http: and file: protocols.  Since you are using localhost, it doesn't matter so you should ignore those warnings.  Finally, if you're having trouble with BlackBoard, be aware they use Java for some of their tools, and their code may be self-signed.  (They are supposed to be fixing that.)  To work around that, you could also add “” to the white-list.

    On the “Advanced” tab, I enable all debugging options, hide the Java console, disable mixed-code verification, enable SSL 3.0 and TLS1.1 and 1.2 (should be the default on new versions), and check the box to make the Java icon appear in the system tray (so I can click on it to show the console).

    Finally, you can copy some Jar files into the MyJars folder, from the JRE/lib folder: javaws.jar.  You can also copy some of the Java DB Jars to there, although it is easier to list them on CLASSPATH.  (Indeed, you can list any Jars on CLASSPATH instead of copying them; this works best when you install in locations without version numbers.)  If you copy Jars, keep in mind you will need to update them when you update the originals, such as installing a new JDK or Glassfish version.

    Another option is to make a symbolic link (a type of short-cut) to the Jars you want, instead of copying them.  On Windows you can make such symbolic links from the command line with the MKLINK command.  For example, “C:\Java\MyJars> mklink javaws.jar C:\Java\jre\lib\javaws.jar”.  (This option won't always work; some Jars internally refer to other Jars with a relative pathname, for example the Glassfish's javaee.jar.)

    Download the Apache Derby DB, latest official release zip.  URL:  Note, the JDK includes this (renamed to “Java DB”), and will install it in %JAVA_HOME%\dbYou only need to do this step if you want the latest version of Derby, replacing the version that came with the JDK.  Make sure you set the DERBY_HOME environment variable appropriately if you don't install to C:\Java\db.

    The Apache Derby zip download includes samples and documentation not included with the Java DB bundled with the JDK.  You can download the zip and extract just those extra folders, into JAVA_HOME/db.

    (Note, there is a pair of Eclipse plug-ins available from the Apache Derby site, if you want them.  Download those, and extract the zip files into the C:\Program Files (x86)\eclipse\plugins\ folder, after installing Eclipse.)

    The database Jar files (there are several) need to be put on CLASSPATH, or copied (or linked) into MyJars.  This was done already, when you set CLASSPATH earlier.

  2. Apache Ant, the “zip” archive of latest version.  (URL:  The archive contains one folder, “apache-ant-version”.  Extract it to C:\Java, and rename the new folder to just “ant” (that matches the environment variable settings created earlier).
  3. Apache Maven, the binary “zip” archive of latest version.  (URL:  The archive contains one folder, “apache-maven-version”.  Extract it to C:\Java, and rename the new folder to just “maven” (that matches the environment variable settings created earlier).
  4. JUnit, the latest version.  (URL:  This site has recently (3/2013) changed, and the new procedure is rather complicated.  From the download page, click the link for “junit.jar”.  You need to download the “jar” and the “javadoc.jar” for the latest version (currently, that is 4.11).  In my browser, that required a right-click and opening the link in a new tab.  Next, rename “javadoc.jar” to “”.  Now you can extract the contents to a new folder; I used “C:\Java\JUnit-API”.  You can then set a bookmark (or favorite, depending on your browser of choice) to the index.html file in there, for quick reference.  The downloaded “junit-version.jar” jar file should be put into C:\Java\MyJars.

    You can repeat these steps for the “hamcrest-core.jar” file.  (Hamcrest is an extension to JUnit.)

    Finally, you can bookmark the JUnit documentation, from and (The JUnit Cookbook, and the combined JUnit and Hamcrest Java Docs (API).  Note the API documentation found here may not be as current as the versions you downloaded.)

  5. Download json-lib.jar from  Or, download org.json.jar from or from  (This package is simpler than json-lib, but no longer maintained.)  Put the jar file into C:\Java\MyJars.
  6. Note!  You can skip this step, and let NetBeans install Glassfish for you, as shown below.  Otherwise, install Glassfish as follows:

    Glassfish Java EE server, the latest open source, multilingual, full platform version.  There are multiple versions, some from Oracle.  I installed the free, open source version from Oracle, which is named the “Java EE SDK”.  (Don't download any of the bundles.)  Download the Windows installer from  (Or you can download the FLOSS version directly (as a ZIP archive) from  Install it as C:\Java\glassfish4; the default is C:\glassfish4.

    The version I downloaded (from Oracle) lacks JAXB Jar files; these are referenced by the Glassfish javaee.jar.  To fix, I downloaded the latest version of JAXB from, and unzipped the folder into C:\Java.  Then I copied the jaxb-api.jar and jaxb-core.jar files into C:\glassfish4\glassfish\modules\.  Doing this stopped the “bad path” warning messages when running the command “javac -Xlint:all”.

    Next time, I'll try the FLOSS download instead and see if it works better. 
    Update:  It didn't work any better; still had to copy those JAXB jars over!)

    Run the installer, and choose “typical install”.  Select the location to install to (“C:\Java\glassfish4”).  Make sure you choose to install the “update tool” on the next screen.  (If you don't see that option — some versions won't have it — you can later run the updatetool.bat script from the ...\bin folder to install it.)  Then, click the Install button to proceed.  When done, a single domain will be created.  (You don't need more than one.)  This uses the user name “admin”, with no password by default.  You can add a password for better security (and notadmin” or something equally easy to guess).  At HCC, no password was set.

  7. EclipseLink, the latest version.  (URL:  Download the zip file, and extract the eclipselink folder to C:\Java\ (resulting in C:\Java\eclipselink).  (If you install elsewhere, remember to change the ECLIPSELINK_HOME environment variable.)  Complete the EclipseLink setup by copying the eclipselink.jar file to MyJars.
  8. (Optional) Any hex editor, such as the free Neo from HHD Software, the latest version.  (URL:  Run the installer, using the defaults for everything.
  9. (Optional) Stand-alone Git tools for Windows.  You might install Cygwin which installs a full POSIX and Linux-like set of tools, including a Bash command line, git, SSH, and many other tools, or you can install a GUI Git tool such as Tortoise Git.  But the easiest solution may be to install Git for Windows, which includes both a limited Bash and command line utility set, just enough for working with Git, and a GUI as well.

    If you install both Cygwin and Git for Windows, both Git tools may end up listed on PATH.  You will probably need to adjust the PATH so all systems use a single git.exe.  Cygwin's Git tool also may cause problems with file endings, due to the configuration defaults.  If that happens, either adjust PATH to use the other git.exe, or change the core.autocrlf setting for Cygwin's git to true and see if that solves the problem.

  10. (Optional) HashCalc, from  This free program can calculate hash codes (also known as message digests or cryptographic checksums).  This is useful to verify the integrity of downloaded software, or to learn about hash codes such as MD5.
  11. All the required software should now be installed, except for Eclipse and NetBeans.  (The installation of those tools is discussed next, as is the setup of the Glassfish server.)  To test all software installed so far, open a fresh command line window, and run these commands:
       java -version
       javac -version
       ant -version
       mvn -version
       ij NUL
       java org.junit.runner.JUnitCore

    (Run the following only if you installed Glassfish already:)

       updatetool --version
       echo exit |asadmin

    You should not see any error messages.  The JUnit test should show 3-5 lines, starting with the version, and ending with “OK (0 tests)” (or some other number, depending on the version).  The updatetool command will pop-up a GUI window showing a version.  The asadmin command line should show something similar to “Use "exit" to exit and "help" for online help.  Command multimode executed successfully.

    You may get a message from your firewall software when running some of these tools and servers.  (Microsoft firewall may block some out-going connections.)  So you may need to enable Glassfish (and JRE) network connections.

    If you do get any errors, run the command “set” (or use the Rapid Environment Editor tool) and check the values of the environment variables very carefully!  On older versions of Windows, you may have to reboot after changing any environment variables, and not just open a fresh command line window, to have the changes take effect.

  12. Eclipse IDE for Java EE Developers, latest Windows 32-bit version.  (URL:  The archive contains one folder, “eclipse”.  Extract it to “C:\Program Files (x86)”.  (On older, 32-bit computers, you don't have that folder.  Instead, extract the archive to “C:\Program Files”.)  For convenience, you can make a short-cut to the eclipse.exe file within the newly installed folder, and put it on your desktop, quick-launch bar, or the Start menu.

    (Note, Eclipse may install a duplicate version of some utilities such as Ant and Glassfish.  If you don't install the extra versions, the default project settings will be incorrect.  To use ant, JUnit, etc., you must manually edit all the project defaults to use the utilities you installed separately, or edit the Eclipse project templates.  For me, it was easier to waste the disk space and just install the extra copies of the tools.  Keep in mind that the versions of these tools may drift apart if you update one and eclipse updates the other at different times.)

    Tip:  Eclipse can be installed on a Flash drive instead.  That way, you can carry around your development environment where ever you go.  (Make sure to also put your Eclipse “workspace” on the same Flash drive; see below for details on that.)

    Run Eclipse to make sure it works.  Make sure it can find your JDK (it will if you set the environment variables correctly).  When you first launch Eclipse, it will ask where to create a workspace, which is a folder that holds all your Eclipse Java projects.  I usually put that in my Java programs folder (see step 2 above), or in “My Documents”, and name the new folder “eclipse-workspace”.  I then check the box to use that as the default and never ask me again.

    Screen-shot of Eclipse screen to set a workspace

    Sometimes, Eclipse won't install completely and the “update” function won't work, because it doesn't have the correct URLs in the “Available sites” list.  If that happens to you (it did to me!), manually add the standard URLs as shown in this screen-shot (use Google to find the correct URLs, if you use a newer version):

    Screen-shot of Eclipse screen to set update URLs

    Under the “Help” menu, run the “check for updates”.  You can also explore what add-ons (plugins) are available by clicking on the “Help→Install new Software...”, and install a few if you wish.  First, select “--All Available Sites--” from the drop-down list at the top.  Then check the boxes at the bottom to show only the latest versions, to contact all update sites during install, and to hide items already installed.  In particular, you should make sure the Git client is installed, from the “Collaboration” list:

    Screen-shot of Eclipse screen 1 to install add-ons

    Screen-shot of Eclipse screen 2 to install CVS and Git add-ons

    In Eclipse, you want the EGit add-on; the JGit add-on is a library that you can use in your Java programs to have them work with Git repositories.  JGit is actually used by EGit internally, and it will probably be installed as a dependency (depends on which version you use).

    Try creating and running a “Hello, World” application.

  13. NetBeans, the latest version for the Java EE bundle.  (URL:  Unlike Eclipse, NetBeans has an installer.  Install NetBeans.  The screen-shots that follow show the installation main steps, including the installation of Glassfish and an extra copy of JUnit.  (Don't re-install Glassfish if you did that already, or at least not to the same location.)

    Screen-shot of NetBeans install screen one

    Screen-shot of NetBeans install screen two

    Screen-shot of NetBeans install screen three

    Screen-shot of NetBeans install screen four

    When done, launch NetBeans and run the menu item “Help→Check for Updates”.  After installing updates (and restarting NetBeans), you may need to update or install additional plugins.  To update or install plugins, use the “tools→Plugins” menu.  Make sure you install at least Git, if not installed by default (depends on the version of NetBeans you install).

    NetBeans now installs Git and some other versioning system clients by default, so they don't show as plugins.  Currently, it doesn't install CVS by default, so you will need that plugin if you plan on using that.

    Try creating and running a “Hello, World” application.

  14. Before running Glassfish for the first time, run the GUI tool “updatetool.exe” tool (launch from the command line), and install all available updates.  You can also install additional add-ons if you wish.

    Now test out Glassfish, by starting the default domain:

       asadmin start-domain

    This shouldn't show any error messages, except if Glassfish is already running when you use “start-domain”; that would be fine.

    Finally, open a web browser to the URLhttp://localhost:8080/”.  Explore the server a bit.  Notice you can run the updatetool from there.  Click the link to go to the “Admin Console”, and explore that.  See if you can figure out how to download and install sample applications from there.

    When done, you can shut down the Glassfish server with:

       asadmin stop-domain

Post-install Steps

To make development and testing more convenient, you can do some or all of these additional steps:

  1. Make a folder to hold your Java programs and projects.  At HCC, we use “C:\Temp”.  At home, I use “C:\%HOMEPATH%\Java”.  (On Windows 7, that becomes “C:\Users\wpollock\Java”.)
  2. Make a copy of the “command prompt” (cmd.exe) short-cut you can find in the Start menu.  Rename the copy to something like “Java CLI”.  Edit the properties of the new short-cut, to start in your Java folder (see the previous step).  You can also change the font and layout (number of rows and columns).  It is also handy to enable “Quick Edit Mode”.  This short-cut can be placed on the desktop, in the Start menu, or “pinned” to the taskbar.  (I put it in both the Start menu and taskbar.)
  3. Open the folder where you installed Eclipse, and right-click on eclipse.exe, and choose copy.  Then, you can “paste shortcut” in your Start menu, desktop, or the taskbar.  (NetBeans installs a desktop short-cut and a Start menu item, but you can still pin that to the taskbar if you wish.)
  4. You can add items to your right-click→send to menu.  I like to put a short-cut to Notepad (or your favorite text editor) there.  You can find the folder holding the items for this menu at “%APPDATA%\Microsoft\Windows\SendTo”.  (Notepad.exe is usually found in C:\Windows.  Right click it, copy, then open the “SendTo” folder, and paste as a short-cut.)

    A better editor in my opinion is the free “Notepad++”.  (URL:

  5. If you turn off word-wrap in Notepad, you can enable the status bar, which shows the current line and column.  That is handy when you get an error message about line 234 (or whatever), and you can see what line that is.  (Also, control+G allows you to jump to any line.)
  6. Glassfish can be set to run as a Windows service, so it is always running.  Otherwise, you will need to start it running every time with “asadmin start-domain”.  If you don't want to be running this always, you can make it more convenient to start and stop using a short-cut.  You can make a pair of BAT files, one to start and one to stop glassfish.  A good place for them might be “%GLASSFISH_HOME%\bin”, but if you do place them there and later update or reinstall Glassfish, they may be gone!  Personally, I created a new folder called “C:\program Files (x86)\Utils”, and listed folder that on PATH.  Then I put any BAT files or other DOS software I download in there.  You can also add a short-cut to them from the Start menu, desktop, or taskbar.
  7. In your favorite web browser, you will want to make a bunch of favorites/ bookmarks, to various Java related documents and your Glassfish server.  The ones I find most useful are:

    Java 8 API (
    Java 8 SE docs (
    Junit API (
    Java EE API (
    Java EE tutorial (file:///C:/Java/glassfish4/index.html)
    Glassfish HTTP application server (http://localhost:8080/)
    Glassfish HTTPS application server (https://localhost:8181/)
    Glassfish Administration console (http://localhost:4848/)

    Others bookmarks can be useful too, such as the one for the (older but useful) JUnit Cookbook, and documentation links for Ant (file:///C:/Java/ant/manual/index.html), Maven, Derby, Git, and Glassfish.  Documentation often includes tutorials, quick-start guides, FAQs, and reference material.  Find and bookmark any you find useful.  (You can also download zip archives of the Java API docs for Java SE, JNLP (WebStart), JUnit, etc.  Then you can bookmark the local copies.  This can be useful when you have intermittent network access.  Don't forget to bookmark the locally installed JavaFx docs, and all the demos and samples as well.  Explore the folders in JAVA_HOME to see what's available.)

  8. Open the Java control panel, and adjust any settings you don't like.  (My preferred settings were discussed above, in the JDK install step.)  From the “Security” tab, you can control if Java is enabled in the web browsers.  You will want that if you are using for your coursework.
  9. Make a short-cut in the Start menu for the WebStart downloaded applications: Locate ...\jre...\bin\javaws.exe, and add a short-cut from it to the Start menu.  (You can name the short-cut “Java WebStart”.)  Modify the short-cut properties by adding “ -viewer” to the end of the command line (“Target”).

    image of Java WebStart shortcut's properties

    That command launches the Java control panel's application (WebStart) cache.

  10. Customize the items on the Start Menu→Programs list.  I like to create a new folder in there called “Java”, and add short-cuts to all programs there (including some for Glassfish that don't get otherwise added anywhere in the Start Menu).