Installing Other Software

1. Apache Tomcat (http://tomcat.apache.org/)

a. Download the latest version of Apache Tomcat (currently 9.0.24). All you need is the core binary distribution. There are two versions available, a Windows Service Installer version or the zip version (e.g. 64-bit Windows zip). I recommend using the zip version. Unzip the file into C:\Java, creating a directory named something like C:\Java\apache-tomcat-9.0.24.

b. Create an environment variable CATALINA_HOME for the directory where Tomcat is installed; e.g., C:\Java\apache-tomcat-9.0.24. Create a second environment variable TOMCAT_HOME with the value %CATALINA_HOME%.

c. Add %CATALINA_HOME%\lib\servlet-api.jar to your CLASSPATH environment variable, and add it to the build path in Eclipse for your projects that use servlets and JSPs. For convenience, so that you don’t have to change the Eclipse build paths every time you install a new version of Tomcat, you can create a separate directory (e.g., C:\Java\apache-tomcat\lib), copy servlet-api.jar to this folder, and then add this copy to the build path in the appropriate Eclipse projects.

d. Test your installation by starting Tomcat and opening a browser with the link http://localhost:8080. You can start Tomcat by opening a command prompt, navigating to %CATALINA_HOME%\bin, and typing the appropriate startup command file (e.g., startup.bat for Windows or startup.sh for Linux/Unix.) If everything is set up correctly, you should see something similar to the following in your browser:

2. (http://db.apache.org/derby/derby_downloads.html)/ Note that other database systems such as Express Edition, MySQL, Microsoft SQL Server, SQLite, etc. can be used.

a. Download one of the later versions of Apache Derby; e.g., 10.14.2.0 (recommended) or 10.15.1.3. There are several distributions available, but only the “bin” distribution is needed. The file will have a name similar to “db-derby-10.14.2.0-bin.zip”. Note that a version of Derby is included with some versions of the Java JDK under a different name, JavaDB, but I recommend that you install Apache Derby instead.

b. This is simply a zip file, and I recommend that you unzip it in the same C:\Java directory as the other software, creating the directory C:\Java\db-derby-10.14.2.0-bin.

c. Create the environment variable DERBY_HOME with the value of the install directory for Derby; e.g., C:\Java\db-derby-10.13.1.1-bin.

d. Add the %DERBY_HOME%\bin to your PATH environment variable.

e. Add the following to your classpath: %DERBY_HOME%\lib\derby.jar;%DERBY_HOME%\lib\derbytools.jar; %DERBY_HOME%\lib\derbynet.jar;%DERBY_HOME%\lib\derbyclient.jar;

f. For web applications, I recommend that you copy both derby.jar and derbyclient.jar from %DERBY_HOME%\lib to %CATALINA_HOME%\lib.

g. Derby can run in either embedded mode or server mode. I recommend that you run Derby in server mode. To test your installation, start the Derby network server by opening a command prompt, navigating to %DERBY_HOME%\bin, and invoking the appropriate command file, either startNetworkServer.bat for Windows or startNetworkServer for Linux/Unix.

h. Test your installation by opening a command prompt and typing “sysinfo”. You should see information about your Java installation, your Derby installation, and your Derby locale information.

i. You can create a database by running SQL Workbench/J (see item 3 below) or the Derby utility “ij” at a command prompt. Create a database using a command similar to the following (all on one line): connect 'jdbc:derby://localhost:1527/C:\\Java\\Derby- Databases\\DBName; create=true' user 'username' password 'password';

Of course you should substitute the correct path for your database and the correct user name and password. Exit ij by entering “exit;”

3. SQL Workbench/J (https://www.sql-workbench.eu/index.html). Note that other database explorers can be used such as SQuirreL SQL Client, Oracle SQL Developer for an Oracle Database, MySQL Workbench for a MySQL database, DB Browser for SQLite for a SQLite database etc.

a. It helps, but it is not really necessary, to have a software package to facilitate working with databases. If you have a preference for a different database explorer/browser, then please feel free to use that one. Otherwise, I suggest that you download a copy of SQL Workbench/J. Currently, the latest version is Build 125 (2019-05-08). Select the one labeled “Generic package for all systems including all optional libraries”.

b. The download is simple a zip file, which I recommend that you unzip into C:\Java. Doing so will create the subdirectory C:\Java\SQL Workbench-J. There is an executable called SQLWorkbench64.exe that is used to start the application.

c. I recommend placing a shortcut to SQLWorkbench64.exe somewhere on the desktop.

d. Before you use SQL Workbench/J, you will likely need to add an appropriate JDBC driver. Here is an example of how to add a JDBC driver for Derby. Other JDBC Drivers are added similarly. Start SQL Explorer and navigate to File → Manage Drivers… Select the one labeled “Apache Derby Network Client”. Click on the folder icon on the right, navigate to %DERBY_HOME%\lib, and select the file derbyclient.jar. Click “List Drivers”, and select org.apache.derby.jdbc.ClientDriver.

4. In setting up Eclipse projects you might want to add external libraries to the build path. For example, to write a servlet you need to extend class HttpServlet, and you have to tell Eclipse where to find the jar file that contains the servlet classes. Similarly, you might need to add jar files for JDBC drivers, XML processing libraries, etc.

Here are the directions for adding servlet-api.jar from Tomcat into your build path. Other external libraries are added in a similar manner. a. Right click on the project and select Build Path → Configure Build Path... b. Select the Libraries tab, and click on Add External Jars... c. Navigate to CATALINA_HOME\lib and select servlet-api.jar

Note: If you update Tomcat on a regular basis as new versions are released, you might want to keep a copy of servlet-api.jar in a directory that is more permanent than the Tomcat installation directory; e.g., C:\Java\apache-tomcat\lib. In step c above, link to the copy in the more permanent directory.