installing jdk and tomcat
Skip this Video
Download Presentation
Installing JDK and Tomcat

Loading in 2 Seconds...

play fullscreen
1 / 17

Installing JDK and Tomcat - PowerPoint PPT Presentation

  • Uploaded on

Installing JDK and Tomcat. Vijayan Sugumaran Department of DIS Oakland University. Downloading JDK. JDK 6 (J2SE v1.6.0_03) installer can be downloaded from the following url: Click on the Download button

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about ' Installing JDK and Tomcat' - acton-bright

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
installing jdk and tomcat

Installing JDK and Tomcat

Vijayan Sugumaran

Department of DIS

Oakland University

downloading jdk
Downloading JDK
  • JDK 6 (J2SE v1.6.0_03) installer can be downloaded from the following url:
  • Click on the Download button
  • Click on Accept (license agreement) and continue
  • Click on the link for online installation:
    • Windows Online Installation, Multi-language
    • Run the installer
  • Accept all the default settings. It will create a new directory (C:\Program Files\Java\jdk1.6.0_03) and there will be a subdirectory called “bin” which contains all the jdk tools (javac, java, etc.). There will also be another subdirectory called “lib” that contains the .jar files
setting environment variables
Setting Environment Variables
  • In order to access the java binary files from any directory, we should set the PATH environment variable
  • To access .class files from other locations, we need to set the CLASSPATH variable.
  • The CLASSPATH variable can also indicate where to look for .jar files
setting path and classpath
Setting Path and Classpath
  • Right mouse click on “My Computer” and select the “Properties” option
  • The system properties panel will pop up. Click on the “Advanced” tab.
  • Click on the “Environment Variables” button
  • If the Path and Classpath variables are already defined, then you can add values at the end by clicking on the “Edit” button.
  • The directories are separated by semicolon
  • If the variables don’t exist, then you can create them by clicking on the “New” button, and enter the values for those variables (see next slide)
  • The first value for the classpath variable should be “.;” that indicates current directory
downloading and installing tomcat
Downloading and Installing Tomcat
  • Download url:
  • Scroll down to the Binary Distributions section and click on the zip link under Core to download tomcat 6.0.14.
  • The downloaded zip file needs to be unzipped. You can put the contents under Program Files or anywhere else you like.
configuring tomcat
Configuring Tomcat
  • Make sure the “JAVA_HOME” environment variable exists. If not, create this variable and set it to C:\Program Files\Java\jdk1.6.0_03 (or the directory where jdk resides)
  • For now, leave the port to 8080 (you can change it to another port number later in the server.xml file)
  • Turn on Servlet Reloading
    • Open the context.xml file (C:\Program Files\apache-tomcat-6.0.14\conf\context.xml) using notepad
    • In the context.xml file, change to (it is case sensitive)
      • configuring tomcat contd
        Configuring Tomcat (Contd)
        • Enable the Invoker Servlet
          • Uncomment the servlet and servlet-mapping elements in the web.xml file (C:\Program Files\apache-tomcat-6.0.14\conf\web.xml)
          • (remove this line)
          • (remove this line)
configuring tomcat contd1
Configuring Tomcat (contd)
  • Turn on Directory Listings when there is no welcome-file (optional)
    • Edit the conf/web.xml file as follows








test the server
Test the Server
  • Start the server
    • Click on C:\Program Files\apache-tomcat-6.0.214/bin/startup.bat
    • Open a browser window and type the url: http://localhost:8080/
    • The Tomcat page should show up
  • Try some simple HTML and JSP Pages
  • Try executing the servlet examples
  • Need to set up a development environment so that you can compile your own servlets. They need to be in a specific locaiton.
setting up the application directory structure
Setting up the Application Directory Structure
  • Create a directory for each application within the webapps (C:\Program Files\apache-tomcat-6.0.14\webapps) directory and the necessary sub directories within it.
  • Example:
    • Create a directory called “HelloApp” for the “hello world” application within the webapps directory
    • Within HelloApp, create a subdirectory called “WEB-INF”
    • Within WEB-INF, create a subdirectory called “classes”
    • The compiled servlets have to reside in the “classes” directory
creating compiling executing a servlet
Creating, Compiling & Executing a Servlet
  • Type the code for the Hello servlet using notepad
  • Save it as in the following directory:

C:\Program Files\apache-tomcat-6.0.14\webapps\HelloApp\WEB-INF\classes

  • Add the path for the servlet-api.jar and jsp-api.jar files to the classpath variable
    • (C:\Program Files\apache-tomcat-6.0.14\lib\servlet-api.jar; C:\Program Files\apache-tomcat-6.0.14\lib\jsp-api.jar; )
  • Compile the file using javac
  • The Hello.class file will be created and it should also reside in the same classes directory
  • Executing the Hello servlethttp://localhost:8080/HelloApp/servlet/Hello
creating a new web application
Creating a New Web Application
  • Steps to create a new web application called “anotherapp”
    • Create the appropriate directory structure
    • Restart Tomcat
    • Add one or more servlets to the application
    • Test the servlets
    • To control the behavior of this application add web.xml file to the WEB-INF directory
    • If a web.xml file is not provided for this application, the install_dir/conf/web.xml file will be used
creating the directory structure review
Creating the Directory Structure (Review)
  • Create a folder called “anotherapp” (or any other name you choose) within the install_dir/webapps folder
  • Create the “WEB-INF” folder within the “myapps” folder
  • Create the “classes” folder within the “WEB-INF” folder
  • For now, make sure that you don’t have web.xml file within the WEB-INF directory
remaining steps
Remaining Steps
  • Restart Tomcat
  • Add one or more servlets to the “anotherapp” application
    • Create the servlet source file (.java file) in the install_dir/webapps/anotherapp/WEB-INF/classes directory
    • Compile the source file using javac
    • Alternatively, you can put the source file(s) anywhere you want, compile them, and then move the .class files into the install_dir/webapps/anotherapp/WEB-INF/classes directory
  • Test the servlet (say you created Hello.class)
    • http://localhost:8080/anotherapp/servlet/Hello
deployment descriptor file web inf web xml
Deployment Descriptor File – WEB-INF/web.xml
  • The install_dir/conf/web.xml file controls the behavior of all the web applications that are under the webapps directory
  • If you want a particular web application to behave differently, then you add the web.xml file within the WEB-INF directory
  • It is not absolutely necessary that you should have the web.xml file for the application
  • Among other things, the web.xml file may contain the values of parameters that would be used during servlet initialization (calling the init() method)