Java Web development BASICS (1)-Environment

Source: Internet
Author: User

Part 1 installation in the Java environment
1. download the latest j2sdk version from Sun's official website. Here I download 1.5.0
2. Follow the prompts to install the tool. Note that no space is required in the installation path.
Here I install it to D:/jdk1.5.0
3. Configure Environment Variables

First, let's take a look at what is an environment variable?

Environment variables are designated lights for Operating Systems, Applications, script programs, and so on, which can tell them where the resources they need are. Most systems have some preset environment variables. We can also add our own environment variables.

Commands related to environment variables in Windows

Enter set in the DOS window prompt, and press enter to view all environment variables in the system;

If you want to see a single variable, enter "set variable" or "Echo % variable %" in the DOS window prompt, and press Enter;

If you want to set an environment variable, enter SET variable name = "variable value" in the DOS window prompt, and press Enter.

In Windows, Java mainly uses three environment variables: java_home, classpath, and path.

Java_home points to the JDK installation path. In this path, you should be able to find the bin, Lib, and other directories.
The values of path and classpath are ordered directories. Tell the system or application where to find the resources they need.

The PATH variable allows us to run Java applications, such as javac, Java, and javah, anywhere in the system.

The classpath environment variable is used to let the Java interpreter know where to find the class when we need to reference classes written by others when developing Java programs. Sun usually provides us with some additional rich class packages, one of which is DT. jar, one is tools. jar, these two jar packages, So we usually add these two jar packages to our classpath environment variable.

Therefore, we create the following system environment variables:
Java_home value: D:/jdk1.5.0
Classpath value:.; % java_home %/lib
Because classpath automatically searches for the. jar file and. Class file when searching for a path, you only need to write the classpath path to the lib directory.
Modify the PATH value of the system environment variable
Add % java_home %/bin before the original value;

Part 2: Introduction to Tomcat Environment

Tomcat is an important sub-project in the Jakarta project, and it is also the servlet and JSP Container officially recommended by Sun (see http://java.sun.com/products/jsp/tomcat/ for details ).

What are JSP and Servlet?

JSP is a script embedded with Java code in common HTML. At this point, it is the same as other scripting languages (such as PHP, but it is different from other languages: Other scripting languages are directly interpreted by the server, while JSP is first converted to servlet by JSP containers (such as Tomcat, then call javac to compile the servlet into a class file. In the end, the server interprets the class file. So what is Servlet? Servlet is actually a special Java class. Servlet classes generally inherit from the httpservlet class. In this class, at least doget or dopost functions must be implemented, process the request from the customer in the two functions and return the result. Servlet and JSP are important parts of Sun's J2EE architecture. Because it is based on the Java language, it can easily call powerful Java APIs (such as JDBC ).

The installation of Tomcat is relatively simple. It can be installed by default. Note that there are no spaces in the installation path.

The main directory after tomcat installation is as follows:

Tomcat directory structure

Directory Name

Introduction

/Bin

Store startup and shutdown Tomcat scripts

/Conf

Contains different configuration files, server. XML (main configuration file of Tomcat) and Web. xml

/Logs

Store log files

/Webapp

Store the application example. The application you want to deploy will also be placed in this directory.

/Work

Tomcat stores the servlet generated by JSP in this directory

/Common/lib

Stores jar files accessible to Tomcat servers and all web applications.

After the installation is complete, enter http: // localhost: 8080/in the browser. If the Tomcat homepage appears, the installation is successful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.