(Last updated: April 17, 2013)
This document describes the steps to install and configure various Java software 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 describe here conforms to Oracle (formerly Sun) recommendations for 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 JREs. 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 Eclipse and
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 set up
PATH and other
environment variables to refer to those locations, these tools are
small and it doesn't hurt to install the extra versions that come with
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.)
Note that these directions are tested on Windows 7. If you wish any additional help, don't hesitate to ask!
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 the standard
C:\Java\glassfish3(which is where we will install the Glassfish Java EE server).
This make a backup copy of all your environment variables, always a good idea before making changes that can prevent your system from working correctly. Print it out, just in case.
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
Just put the
QTJava.zip file in the
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!
Add these entries to the
PATH environment variable:
C:\Java\bin C:\Java\ant\bin C:\Java\maven\bin C:\Java\db\bin C:\Java\glassfish3\bin
(Using environment variables in
such as “
instead of “
C:\Java\bin”, just won't work in
The order these are listed in
PATH shouldn't matter.
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
You don't need to list both locations unless you plan on installing multiple
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\jre7\bin) must precede
the JDK's private JRE (
PATH, or the public JRE won't be used.
You can also just not install the public JRE when running the installer, but I don't recommand that. Windows contains a registry setting used by some apps (some IDEs, web browsers, etc.) to find a JRE to use. 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 is why it sometimes requires a reboot when updating Java, before the new version is used by all applications.)
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
(or some other location already listed on
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
Remember that both
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
FOO;BAR — Good! FOO; BAR — No good! FOO:BAR — No good!
Download and install the development tools in this order:
This installer includes several sub-installers.
The first one is for the JDK.
Change the install location to “
and later you can let the JRE install in its default
Install everything, including samples and demos, and the source code if
When you use Java's automatic updater for Windows, third-party software is 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 Ask.com, 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.
C:\Java, and rename the new folder to just “
ant” (that matches the environment variable settings created earlier).
C:\Java, and rename the new folder to just “
maven” (that matches the environment variable settings created earlier).
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 “
javadoc.zip”. 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.htmlfile in there, for quick reference. The downloaded “
junit-version.jar” jar file should be put into
You can repeat these steps for the “
(Hamcrest is an extension to JUnit.)
Finally, you can bookmark the JUnit documentation, from https://github.com/junit-team/junit/wiki and http://junit.sourceforge.net/doc (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.)
Glassfish Java EE server, the latest open source,
multilingual, full platform version.
Install it in
the default is
(Note, there is a commercial version from Oracle as well as the open source
I installed the free, open source version.)
Run the installer, and choose “typical install”.
Select the location to install to
Make sure you choose to install the “update tool” on the
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
You can add a password for better security (and not
admin” or something equally easy to guess).
At HCC, no password was set.
%DERBY_HOME%\libfolder 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.
java -version javac -version ant -version mvn -version ij NUL sysinfo 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).
updatetool command will pop-up a GUI
window showing a version.
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 blocks out-going connections, not incoming ones. So you may need to enable Glassfish (and JRE) network connections.
If you do get any errors, run the command “
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.
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.exefile 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. For me, it was easier to waste the disk space and just install the extra tools.)
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 1 above),
or in “My Documents”, and name the new folder
I then check the box to use that as the default and never ask me again.
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:
Under the “Help” menu, run the “check for
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
In particular, you should make sure both the CVS and
Git clients are installed, from the “Collaboration” list:
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.
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 CVS and Git.
NetBeans installs git and some other versioning systems by default, so they don't show as plugins. Currently, it doesn't install CVS by default, so you will need that plugin.
Try creating and running a “Hello, World” application.
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:
This shouldn't show any error messages, except if Glassfish is already
running when you use “
that would be fine.
Finally, open a web browser to the URL
Explore the server a bit.
Notice you can run the updatetool from there.
Click the link to go to the “Admin Console”, and
See if you can figure out how to download and install sample applications
When done, you can shut down the Glassfish server with:
To make development and testing more convenient, you can do some or all of these additional steps:
C:\Temp”. At home, I use “
C:\%HOMEPATH%\Java”. (On Windows 7, that becomes “
cmd.exe) short-cut, renamed 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). 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.)
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.)
Notepad.exeis 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: http://notepad-plus-plus.org/download/.)
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.
Java 7 API (http://download.oracle.com/javase/7/docs/api/) Java 7 SE docs (http://docs.oracle.com/javase/7/docs/) Junit API (http://kentbeck.github.com/junit/javadoc/latest/) 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 JUnit Cookbook, and documentation links for Ant, Maven, Derby, and Glassfish. This documentation often includes tutorials and 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.)
...\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”). That command launches the Java control panel's application (WebStart) cache.