Java Development environment

Source: Internet
Author: User
Tags tomcat server

The main content of this article is from: http://blog.csdn.net/cxwen78/article/details/6400798. The article has changed the original text.

1. Development tools Get

    • Development Kit JDK: available on the Oracle company website (http://www.oracle.com/) for download. The internet may be slow, or you can download the JDK from other sources.
    • Java Web Application Web server Tomcat:tomcat official website (http://tomcat.apache.org) on the left side of the official website download gives a variety of Tomcat versions, select a version to the download page; Click the latest version hyperlink (such as 7.0.42) in the navigation area to navigate to the bottom of the Tomcat download list for each operating system and platform, and to download the appropriate version in the binary Distributions-core column, such as 32-bit Windows zip.
    • Java Development IDE Myeclipse:myeclipse is to pay for this, we can find a xx version of their own. Of course, you can also use the Free Eclipse official website (http://www.eclipse.org). You can use Eclipse IDE for Java EE Developers (206M). The language of the software is English, if you need, you can download some of the Chinese package.

2. Development tool installation and environment configuration

2.1 JDK Installation and configuration

    • Install: Run the downloaded JDK installation files directly and follow the instructions to install them. In the middle of the selection of the JRE installation, also installed. JDK is the Java development platform, when writing Java programs, the JDK needs to compile processing, the JRE is the Java program environment, contains the implementation of the JVM and the Java Core Class library, compiled Java program must be executed using the JRE. The JDK and JRE are integrated in the downloaded JDK installation package, so you will be prompted to install the JRE during the installation of the JDK.
    • Environment configuration: In the environment variable of "My Computer", add the JAVA system variable, the action is to create a variable named "Java_home" in the "System variables" area, the variable value is the installation path of the JDK, such as "c:/java/jdk1.6.0_25"; then Java_ HOME is added to the system variable path by editing the open system variable path, adding the code in double quotes before the original variable value "%java_home%/bin;", where the semicolon separates and is indispensable.
    • Detection: After installing the JDK, run the JDK command in the CMD Command Line window: Javac. If the installation succeeds, the system interprets the use of Javac, or the system does not recognize the command.

2.2 Tomcat Installation and directory description

    • Installation: After you download tomcat, you can use the
    • directory Description: Bin-A script file that launches and shuts down Tomcat on various platforms. There are two very critical files in this directory,--startup.bat, Shutdown.bat, which are files that start Tomcat under Windows, which are the corresponding closing files; Conf-tomcat's various configuration files, Where Server.xml is the main configuration file for the server, Web. XML is a profile for all the applications, Tomcat-users.xml is used to define Tomcat user information, configure user permissions and security. Lib-This directory holds the jar that is accessible to both the Tomcat server and all Web applications. Logs-log files for Tomcat, and all tomcat logs are stored in this directory. Temp-Temp folder, Tomcat run time if there are temporary files will be saved in this directory. The WebApps directory-web the published directory of the application, placing the Java Web site or war file in this directory, which can be accessed through the Tomcat server. The servlet file generated by the Work-tomcat parsing JSP is placed in this directory.
    • Detection: In the bin directory, double-click the Starup.bat file to run Tomcat, and in browser input: http://localhost:8080, Access Tomcat. If you can display Tomcat's page, it proves that Tomcat is running successfully.
    • If you double-click the Startup.bat file under the Win7 system, only the DOS window will flash through. Additional environment variables need to be configured for Tomcat to function properly. When the configuration is complete, double-click the Startup.bat file. The configuration environment variables are as follows:
      • java_home=c:\program files\java\jdk1.7.0_03
      • jre_home = C:\Program files\java\jre7
      • Tomcat_home:c:\tomcat6
      • classpath=.; %java_home%\lib;%tomcat_home%\lib
      • path=%java_home%\bin

Installation and configuration of 2.3 myeclipse

  • Installation: Run the MyEclipse installation file and
  • configuration: Different versions of MyEclipse may not have the same configuration interface. Here I use the MyEclipse 10,tomcat 7 below for a detailed configuration of this release.
    • Configure the JDK environment   launch myeclipse, select Window--"preferences ..." in the menu bar. (preference) "--" Java "-" Installed JREs ", click" Add "in the right panel, select" Standard VM ", after the next step, select your installed JDK folder at the JRE home and click" Finish ". Go to "Installed JREs" again and tick the JDK environment you just added. Note that the JDK path in the JDK and environment variables in the java_home should be the same. Otherwise, the Tomcat JDK name may be wrong when you start Tomcat in MyEclipse. http://www.blogjava.net/tw-ddm/articles/53499.html
    • To configure Tomcat startup MyEclipse, select window in the menu bar--Preferences ... (preference) "MyEclipse"--"Servers"-"Tomcat 7" set Tomcat server to "Enable" and "Tomcat Home directory" to the Tomcat 7 installation directory. Additional directory options will be generated automatically. Click OK. Browse to the JDK tab under "Tomcat 7" and select the Tomcat 7.x JDK name for the JDK name you just configured. In this case, you should be able to start Tomcat 7.x in the Servers tab in the lower part of MyEclipse. The
    • configuration default encoding is still the window in the menu bar--Preferences ... (preference) "General"--"content type (contents Types)"--"text" and then enter "UTF-8" in "Default encoding", click "Update" "Update" to "UTF-8" The Java class files (Java Properties file) and other character encodings. UTF-8 can be used to identify Chinese encoding.
3. Develop and run Web projectHttp://www.cnblogs.com/sunywong/articles/666875.html

(1) Create a new Web Project

In Eclipse, tap File----> New----> Project, and in the New Project dialog box that pops up, tap Web project---->myeclipse---->java Enterprise Projects---->web project ", click" Next ", enter the project name" Test "in" Project name "and select Java EE in specification level 6.0, last point "Finish".
(2) Create a new JSP fileClick "Test" in the Package Explorer list on the left of Eclipse to expand the project test. Right-click WebRoot----> New----> JSP to create a new JSP page named hello.jsp. Code such as (the callout part of the figure we need to manually add, the rest of the system is automatically generated):

(3) and in the same way, Create a new call hello_result.jsp of the JSP documents;Code such as:
  (4) Deploy (Deployment) project.
The following is a diagram of others, project names may not be consistent, with their own project name. Click the Deploy button (the button with the red line is the Deploy button) and click Add in the popup window to deploy the test project (). If you press the configuration in section 2.3, Tomcat 7 should be selected here
  (5) Start Tomcat server. As shown (a button drawn with a red line is the button that launches Tomcat):

Tomcat initiates output information such as:
6.Results of the project test run:
We can go to Eclipse's workspace directory to see the code of the test project, or go to Tomcat's WebApps directory to see the structure of the test project after deployment. 7. Check Eclipse the settings are correct;
After all the settings have been configured, check that the Eclipse>windows>preferences>tomcat settings are correct, and pay particular attention to seeing if the Tomcat base project is set up correctly, as shown in. Here is a picture of others, if the configuration by 2.3, here Windows>preferences>myeclipse>servers>tomcat>tomcat 7.x page Select Tomecat 7.X Under Server, select Enable, and select the path of the Tomcat server to use. Then select the JDK below the left Tomcat 7.x, and select the Tomcat 7.x JDK name for the JDK environment configured in section 2.3. 4. developing and running Java programs

File->new->java project-> name Java program name Hello_world,finish. In the left side of the Hello_world right-click, New->class, you can create a new Java file, named Hello. In the Hello_world.java file, enter the following code:

public classhello {    public static void main(Stringarg[]){        System.out.println("hello world!");    }}

Save. At the Hello_world project or Hello.java file, right-click, run as, Java application to see the results. The Panel has a green triangular symbol on the right and is the shortcut key for run as, and the green Circle arrow is the new shortcut.

Java Development environment

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.