Java Basic Development Environment Construction

Source: Internet
Author: User
Tags apache tomcat java se
1. Obtain development tools 1. Development Kit JDK ●:

Download from the Oracle official website (http://www.oracle.com.

● Select an object to download:

For a Windows operating system, the last downloaded file name format is: jdk-6uX-windows-i586.exe, where "6ux" represents the version number, which contains JDK and JRE, the file size is about 70 m; for example, if the latest JDK is Java SE Development Kit 6 Update 25, the corresponding file name is jdk-6u25-windows-i586.exe, and the file size is 76.66 MB. Related webpage:

 

 

2. Java Web Application Web server -- Tomcat

 

●:

: Tomcat website (http://tomcat.apache.org)

● Download file selection: download on the left of the official website provides various Tomcat versions. Select a version to go To the download page; click the latest version hyperlink in the quick navigation area to find the Tomcat download list for each operating system and platform at the bottom. Zip corresponds to the version in windows. Tar.gz is a Linux development kit. The following figure shows the relevant page reference guide:

 

 

3. Java Development ide-Eclipse

 

●:

Eclipse official website (http://www.eclipse.org), select download to enter the download list page;

● Select a file to be downloaded: Select Eclipse IDE for Java EE development. The related pages are as follows:

 

● Download the Chinese eclipse package:

Http://www.eclipse.org/babel, on the left side of the Babel project home page, click "Download" to go To the download list page; here select the corresponding version of the Language Pack Based on the downloaded eclipse, such as HELIOS version, click to enter the multi-country Language Pack download page; find the language: Chinese (simplified) Sub-title, which contains the Simplified Chinese package, these packages apply to different Eclipse plug-ins, where BabelLanguagePack-eclipse-zh_3.6.0.v ***. the zip file is the core Language Pack of eclipse. Click to go To the download page to download it. After the download is complete, override the corresponding eclipse folder to successfully Add the Chinese Language Pack. The Guidelines are shown below:

 

 

Ii. Installation and environment configuration of development tools 1. JDK installation and configuration

 

● Installation:

 

Run the downloaded jdkinstallation file jdk-6u25-windows-i586.exe and install it as instructed. Among them, JRE installation is selected in the middle and installed together.

Additional note: Relationship between JDK and JRE

JDK is a Java Development Platform. JDK is required for compiling Java programs. JRE is the runtime environment of Java programs, including JVM implementation and core Java class libraries, the compiled Java program must be executed using JRE. JDK and JRE are integrated in the downloaded JDK installation package. Therefore, a prompt will be prompted to install JRE during JDK installation.

 

 

● Environment Configuration:

Add a Java System variable in the environment variable "my computer". Specifically, create a variable named "java_home" in the "System variables" area, the variable value is the JDK installation path, such as "C:/Java/jdk1.6.0 _ 25". Then, add java_home to the system variable path by editing and opening the system variable path, add the code "% java_home %/bin;" in double quotation marks before the original variable value. The semicolon serves as a separator and is indispensable.

 

● Test:

After installing and configuring JDK, run the JDK command javac In the CMD command line window. Successful results

 

 

 

 

2. tomcat installation and directory description

 

● Installation:

 

After downloading tomcat, you can directly decompress it;

 

 

 

 

 

 

 

 

 

 

 

 

 


● Tomcat key directories and files:

 

 

 

Bin:

Stores script files for starting and disabling Tomcat on various platforms. There are two key files in this directory: startup. BAT and shutdown. bat. The former is the file for starting tomcat in windows, and the latter is the corresponding closing file;

Conf:

Tomcat configuration files, including server. XML is the master configuration file of the server, Web. XML is the configuration file for all web applications, the tomcat-users.xml is used to define Tomcat user information, configure user permissions and security.

Lib:

This directory stores the jar files that can be accessed by the Tomcat server and all web applications.

Logs:

It is used to store Tomcat log files. All Tomcat logs are stored in this directory.

Temp:

Temporary Folder. If a temporary file exists during Tomcat running, it is saved in this directory.

Webapps directory:

The publishing directory of the Web application. Put the Java Web site or war file under this directory, and you can access the file through the Tomcat server.

Work:

Tomcat parses the Servlet File generated by JSP and stores it in this directory.

 

 

● Test:

 

Double-click the starup. BAT file in the bin directory to run tomcat, and enter http: // localhost: 8080 in the browser to access tomcat. The page shown in shows that Tomcat runs successfully.

 

 

 

 

3,

 

Eclipse installation and configuration

 

 

● Installation:

 

After downloading the eclipse, directly decompress the obtained eclipse-jee-helios-sr2-win32.zip file to complete eclipse installation;

 

● Localization:

BabelLanguagePack-eclipse-zh_3.6.0.v *** of the downloaded Chinese package ***. decompress the ZIP file directly to get a directory named eclipse, which contains two folders: Features and Plugins. Select them and copy them to the eclipse installation directory to overwrite the features and Plugins;

 

● Integrated eclipse and tomcat:

In the development process, manual deployment and running of WEB projects are cumbersome and inefficient. Therefore, you need to configure the Tomcat server to eclipse and specify a Web application server for the web project. In this way, you can operate tomcat in eclipse and automatically deploy and run web projects. The configuration steps are as follows:

 

In eclipse, the window -- preference -- server -- Runtime Environment (runtime environments) -- add (ADD) to add the Tomcat server. Select Apache Tomcat v6.0 for the installed tomcat version. Next, click "Browse" to select the tomcat installation directory and click "finish" to complete the configuration. The reference diagram is as follows:

 


 

 


● Specify a web browser for eclipse

 

 

Open eclipse, window -- preferences -- General -- web browser -- select use external web browser -- Select Internet Explorer -- OK.

● Specify the encoding format of JSP pages in eclipse

 

 

 

By default, the JSP page created in eclipse Is In The ISO-8859-1 encoding format. This format does not support Chinese character sets, and garbled characters may occur during writing. Therefore, you must specify a character set that supports Chinese characters. The method is as follows:

Open eclipse, window -- preferences -- Web -- JSP file -- encoding (encoding) -- drop-down select ISO 10646/Unicode (UTF-8)

 

 

● Test the Java Web project Hello World

1) file-New-dynamic web project-enter the project name (such as 1.1)-complete, the project is successfully created;

2) project resource manager -- select a project (such as 1.1) -- webcontent node -- Right-click -- create -- JSP file -- input file name (such as index. jsp) -- complete, and create a JSP file;

3) Open the code window on the index. jsp page and write and output "Hello World !" The Code is as follows:


<% @ Page Language = "Java" contenttype = "text/html; charset = UTF-8" <br/> pageencoding = "UTF-8" %> <br/> <! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" "http://www.w3.org/TR/html4/loose.dtd"> <br/> <HTML> <br/> <pead> <br/> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8 "> <br/> <title> Hello World </title> <br/> </pead> <br/> <body> <br/> <center> hello world! </Center> <br/> </body> <br/> </ptml>


4) after the compilation is complete, save and click the black triangle in the toolbar. In the shortcut menu that appears, select "run mode on server". In the displayed dialog box, select the "set server as project default" check box and click the "finish" button to run the project through tomcat. The displayed browser displays "Hello world!" Well done. Follow these steps:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Iii. Summary

 

Calling... Finished! Although it is very basic, It is not mistaken to cut firewood, the action go...

 

 

 

 

 

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.