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 can use the 64-bit versions.) In our course we will explore many tools including both 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 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 them separately too. That way 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 Glassfish. (There is a chance the installer will locate the tools and configure itself to use those locations.) Note that these directions are tested on Windows 7. If you wish any additional help, don't hesitate to ask! ============= Create these environment variables and set them to where you will install the software (change the values if you plan on installing in different locations): 1) ANT_HOME=C:\Java\ant 2) DERBY_HOME=C:\Java\derby 3) JAVA_HOME=C:\Java 4) MAVEN_HOME=:C:\Java\maven 5) GLASSFISH_HOME=:C:\Java\glassfish3 6) CLASSPATH=.;C:\Java\junit4\junit4.jar It is okay if your CLASSPATH has an additional entry at the end. quickTime installer adds one, but it isn't needed. ============= Add these entries to the PATH environment variable: C:\Program Files\Java\jre7\bin %JAVA_HOME%\bin %ANT_HOME%\bin %MAVEN_HOME%\bin %DERBY_HOME%\bin %GLASSFISH_HOME\bin The order doesn't matter, except the ...\jre7\bin should precede the JDK's bin (%JAVA_HOME%\bin). Otherwise, the public JRE won't be used. So if that is updated but the JDK is not, you end up using the older JRE that comes with the JDK (the "private" JRE). Make sure PATH doesn't already refer to any older JRE or JDK you might have previously installed. Remember, both PATH and CLASSPATH are a list of folders (or, for CLASSPATH, folders and jar files). Each one is separate from the next with a semicolon: FOO;BAR -- Good! FOO; BAR -- No good! FOO:BAR -- No good! ============= Download and then install in this order: 1) JDK 7 32-bit for Java SE, latest version (JDK installed to C:\Java, JRE installed in default location). Install everything, including the source code. URL: http://www.oracle.com/technetwork/java/javase/downloads/ 2) Apache Derby DB latest official release (extracted to C:\Java, and rename the folder created to just "derby"). URL: https://db.apache.org/derby/derby_downloads.html (Note there is a pair of Eclipse plug-ins available from here, if you wish. Download those, and extract the zip files into the C:\Program Files (x86)\eclipse\plugins\ folder, after installing Eclipse.) Note! The Windows JDK installer is supposed to include Derby, renamed to "JavaDB". It is an older version, and the installer may not even show it as an option. Even if it does, I suggest downloading the current version directly from Apache.org. 3) Apache Ant latest version (extracted to C:\Java, and folder renamed to just "ant"). URL: https://ant.apache.org/bindownload.cgi 4) Apache Maven latest version (extracted to C:\Java\, and folder renamed to just "maven"). URL: https://maven.apache.org/download.html 5) junit4.10.zip (or newer version; the comment says "source zip"), (extracted to C:\Java, folder renamed to just "junit4", and the jar file in there renamed from junit-4..jar to just "junit4.jar"). URL: https://github.com/KentBeck/junit/downloads 6) Eclipse IDE for Java Developers, (latest 32-bit version). NOTE! The Eclipse site's download page doesn't have a link for the correct version! This is because the main ("stable") version doesn't support Java 7. Until it does, there is a "patched" version you must use: URL: http://www.eclipse.org/downloads/packages/release/indigo/sr1 Extract the zip to C:\Program Files (x86), where it will make a folder named "eclipse". 7) NetBeans (latest version for Java SE), installed in default location. URL: http://netbeans.org/downloads/ 8) glassfish-3.1.1-windows-ml.exe or newer version (I installed it in C:\Java\glassfish3, not default of C:\glassfish3). Note there is a commercial version from Oracle, and an "open source" version. We use the free open source version from java.net. URL: http://glassfish.java.net/public/downloadsindex.html 9) (Optional) some free hex editor, such as Neo, installed in default location. URL: http://www.hhdsoftware.com/free-hex-editor ================ Copy these four files from the %DERBY_HOME%\lib folder, to the C:\Windows\Sun\Java\lib\ext folder (you may have to create this folder): derby.jar derbyclient.jar derbynet.jar derbytools.jar These jar files must be on your CLASSPATH in order to use the database. While only two files are actually needed, the ones used would depend on the mode of your database (server or embedded). Adding all four to the system-wide extensions directory ensures you can use the Derby database in any mode, and using any JRE. =============== Test all installed software, by opening a fresh command line window, and trying these commands: java -version javac -version ant -version mvn -version ij (type "exit;" at the "ij>" prompt to exit) asadmin start-domain asadmin stop-domain C:\Temp>cd \Java\junit4.10 C:\Java\junit4.10>java org.junit.runner.JUnitCore org.junit.tests.AllTests (This should show 5-6 lines, with "OK (535 tests)" at the end.) You should not see any error messages (except if glassfish is already running when you use "start-domain"; that would be fine). You may get a message from your firewall software. 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 "set" and check the values of the environment variables very carefully! Note on older versions of Windows, you may have to reboot after changing any environment variables, not just open a fresh command line window, to see the changes. ================ Post-install: To make everything more convenient, you can do some or all of these: 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 Windows7, that becomes "C:\users\wpollock\Java". 2) Make a copy of the "command prompt" short-cut, renamed to "Java CLI". Edit the properties of this short-cut, to start in your java folder (see previous step). 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. Now you can "paste shortcut" that in your Start menu, desktop, or pinned to 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.) 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". 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 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 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. 8) Open the Java control panel, and adjust any settings you don't like. You can change some of the settings under "Advanced", such as if the Java icon should show in the system try when a JRE is running, or when to check for updates to the public JRE. 9) Launch Eclipse and NetBeans. For each, run the "check for updates". You can also explore what add-ons (plugins) are available, and install a few if you wish. In particular, you should make sure the CVS client is installed. Eclipse will ask where to create a workspace, which is a folder that holds all your Java projects. I usually put that in my Java programs folder (see step 1 above), named "eclipse-workspace". I then check the box to use that as the default and never ask me again. (NetBeans doesn't ask were to put projects; look for in in My documents\NetBeansProjects.) 10) Make a short--cut in the Start menu for the WebStart downloaded applications: Locate C:\Program Files\Java\jre...\bin\javaws.exe and add shortcut from it to: Start-->programs-->Java-->Java WebStart Modify the short-cut properties: add "-viewer" option to the "cmd line".