Build a java web website Runtime Environment

Source: Internet
Author: User

Open-source projects on the market can basically be classified into two categories: JAVA and PHP. However, for most webmasters, especially those who have little knowledge about software technology, it is easier to choose a PHP open-source project, especially in the past few years, Chinese Open Source PHP projects have been greatly developed in China, resulting in a wide range of mature open source systems such as Discuz, ShopEx, and DedeCMS. However, the java web open-source project itself has the advantages that PHP open-source projects do not possess and is used by some webmasters, such as the technical architecture, security, and universality of database access. In general, PHP is mostly used in small and medium systems, while JAVA can be used in large systems. We will not discuss the comparison between these two languages here, it mainly teaches you how to build the runtime environment of java web open-source projects, especially for webmasters who use java web projects to build websites. They do not know much about JAVA, the selection of the server runtime environment may not be too clear. Next we will introduce how to set up the runtime environment for a java web website. Take the Windows operating system environment as an example:

Step 1: download and install JDK (JDK is the basic environment for JAVA program running, just like. net framework, you must note that, according to the type of the selected server operating system and the number of digits of the operating system, if it is a 64-bit server, select the appropriate 64-bit JDK. Otherwise, an error may occur. I have encountered this in a recent project. The Server is Windows Server 2008 32-bit, however, the downloaded software is still 32-bit. The result is that the java program cannot run after the installation is successful)

You can download the JDK installation package from the official Java website. Select the "Accept License Agreement (agree to the License Agreement)" option on the left and select the JDK of the corresponding development platform as needed.

  

After the download is complete, run the program to install JDK. During the installation process, you can change the default installation path of JDK and JRE.

Step 2: Set environment variables. To enable JDK to compile and run java files, you must set the Path and ClassPath environment variables of the system.

Choose my computer> Properties> advanced system Settings> environment variables.

In the system variables area, click "new" to create three environment variables,

Set variable name: Path, variable value: C: Program FilesJavajdk1.7.0 _ 04bin

Set the variable name: ClassPath, variable value:.; C: Program FilesJavajdk1.7.0 _ 04libdt. jar; C: Program FilesJavajdk1.7.0 _ 04libtools. jar

Set the variable name to JAVA_HOME. The variable value is C: Program FilesJavajdk1.7.0 _ 04.

Step 3: Verify the JDK configuration information

Open the cmd command in Windows, open the command window, and enter java or java-version. If the relevant information is correctly output, the configuration is successful.

  

Step 4: Download Tomcat and decompress the deployment project

Tomcat versions can be divided into two types, one is the installation version, and the other is the decompression version (that is, the green software, can be directly used after decompression ). Here we select the decompressed version. For example, after decompression, we can find the project's root directory webapps from the tomcat directory. What we need to do is copy the source code of the website to be deployed to this directory, for example, copy the project to be deployed to webapps:

  

Step 5: start Tomcat and run the website

How to start the Website: Find the bin folder in the tomcat directory and double-click the startup. bat file, as shown in

  

 

To test whether tomcat is successfully started, visit the address http: // localhost: 8080, as shown in figure

  

 

Run the website. Take upload as an example. Open the URL http: // localhost: 8080/upload (this upload is just a test page written by myself)

  

 

In this way, we can start running our java web project.

Related tips: the tomcat port is 8080. We can set the port as needed. For example, if we want to set it to 8088, we need to modify the server under the conf directory of tomcat. xml, perform the following settings,

  

 

For example, we can also set the default tomcat encoding, for example, your project is UTF-8, if not set, the project will appear in the running process of garbled, therefore, we can add URIEncoding = 'utf-8' in the preceding configuration file. In addition, to make the configuration file take effect, restart tomcat.

OK. With the above configuration, we have completed the establishment of the JAVA WEB runtime environment. In a simple summary, the java web project must have and successfully configure two things to run. One is JDK, one is WEB Server Tomcat (of course, there are other web servers that are charged for java web projects on the market ).

This article by copper http://www.ahdctm.net original, reproduced please indicate the source! Thank you!

Related Article

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.