Quick Start with spring -- 2. helloworld (1)

Source: Internet
Author: User
This article Article Let's talk about spring development. The example is very simple, that is, to output a statement. I will not talk about the configuration of various software here. If you do not understand it, refer to my previous articles. Before reading this article, you 'd better understand IOC, Di, and other concepts and refer to Quick Start with spring-1. Some collected documents. 1. Download and Configuration 1. Required Software · JDK 5.0 · Eclipse-SDK-3.1RC3-win32.zip · Xmlbuddy_2.0.62.zip ·Spring-framework-1.2.1-with-dependencies.zip If xmlbuddy is not visible in eclipse after installation, add the "-clean" parameter after the eclipse command. 2. Configuration ● Configure Eclipse: · Window-> perferences-> JAVA-> compiler: Set "compiler compliance level" to "5.0" · Window-> perferences-> JAVA-> build path: Select "Folders" ● For details about how to create a library folder, refer to "Create a library folder" in "Eclipse Quick Start hibernate -- 1. Getting Started instance. Here Unzip the spring-framework-1.2.1-with-dependencies.zip and paste the spring. jar (in the Dist directory), The commons-logging.jar (LIB/Jakarta-commons directory), The log4j-1.2.9.jar (LIB/log4j directory) these three files are copied to the "D: in the/Java/spring/lib directory, create a "Spring" library in eclipse and add the three files to the "Spring" library. Ii. Project Practices

1. Create a project · Create a Java project: Springhello , Note that you need to import the user library spring. · This is the structure of the entire project after completion (PreView ): · Project source code download (does not contain library files): http://free.ys168.com /? Under the javamxj spring directory. 2. Simple helloworld · Create a new class as follows: Helloworld ; Package name: Javamxj. Spring. beginning1, Code As follows:


Helloworld. Java

Package Javamxj . Spring . Beginning1 ;

Public ClassHelloworld {
Public Static VoidMain (String[] ARGs ){System. Out. println ("Hello world! ");
}
}

OK! It is very simple. I just want it to print a statement "Hello World !". Now I don't want to output "Hello World !", I want to output any statements as I like. It's easy! Set "Hello world !" Replace it with the statement you want to output. However, there is a drawback that every modification requires recompilation. Program . A small program like this does not matter, but if it is a large project, it will be a little annoying. Fortunately, you just need to modify the program a little and enter the parameter. · Create a new class: helloworldwithcommandline under this package, which is also very simple:

Helloworldwithcommandline. Java

Package Javamxj . Spring . Beginning1 ;

Public ClassHelloworldwithcommandline {

Public Static VoidMain (String[] ARGs ){
If(ARGs. length> 0 ){
System. Out. println (ARGs [0]);
}Else{
System. Out. println ("Hello world! ");
}
}
}

· Select helloworldwithcommandline, right-click and choose run as> Run.... In the displayed window, switch to the "arguments" column, and enter "Hello, javamxj!" in "program arguments !", For example, the expected statement is output. The first part is here. Please continue with the second part.

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.