Beginner's Guide Java experts start illustration

Source: Internet
Author: User
Tags add mysql version variable window jboss mysql database port number
Java EE Many people know the Java EE, but how many people really know what it means? Simply put, Java EE is a business application system model, or a specification, that includes a java-based remote method call (RMI), Enterprise-class JavaBean (EJB), Java Messaging Service (JMS), Java Server Page (JSP), and so on. Using the resources of Java EE, we can easily and quickly create a powerful enterprise-class application, such as the toll system of telecommunications, enterprise knowledge management system and so on. You might think that it would take a lot of investment to develop such a powerful system. In fact, we can use the existing network to find free and even open source parts, and then assemble them into a usable system. Our goal is to start from scratch! Of course you have to pay for your own computer:

This article takes the following components as an example to build our Java EE system. Please note the version number of each component, otherwise there may be compatibility between components: the underlying database with MYSQL3.23.35,EJB and Web server with Jboss3.2.3, and development environment we choose the recent very popular eclipse2.1+lomboz2.1.3.

Let's take a step-by-step configuration to develop the various components required for Java EE, and actually create an entity EJB that invokes the contents of the underlying database and displays it with a JSP page

   I. Installation and configuration

1. The first thing we need is a sun jdk, go to Sun's website ( http://java.sun.com/Take a look, find the latest JDK, and download it back. Then release it into a convenient directory, such as D:\worktools\jdk1.4. Right-click My Computer to select Advanced-> Environment variables as shown in Figure one:


(Figure I)


The environment variable is divided into two parts: The above is the user variable area, and the following is the system variable area. In the user variable area, we create a new variable named Java_home that points to the directory of the JDK we just generated, such as D:\worktools\jdk1.4, which we use%java_home. New build a Classpath value of%java_home\lib;%java_home\tools. JAR; In the system variable area, we modify the environment variable of path, add a value%java_home\bin, middle ";" Separated. OK, all the way down, so we've done all the Java development base----JDK settings. (This article takes WinXP as an example, if you use the Win9x system, you need to restart your computer)

2. Almost all enterprise applications require data storage systems, and we will use a well-known Open-source database: MySQL. The version used in this article is mySQL3.23.35, you can go to the MySQL website (http://www.mysql.com) to download.

Install MySQL is very simple, untie download down the package, op "Setup." EXE ", all the Way" Next "can be done, it is recommended to install it in the C:\MYSQL. After installation, there is a mysql\bin named "Winmysqladmin." EXE "program. Run this program, enter your username and password (set yourself), MySQL can already be used. Now you can manipulate the database with its default username "ROOT" password as null.

3. There are generally two ways to operate a database, one is the console and the other is a graphical operation. For the sake of simplicity, we choose the latter way. and the choice of software is mysql-control-center0.9.4, it is also produced by MySQL Group, the biggest advantage is free! After installing MYSQL-CC on the MySQL Web site, a shortcut is generated on the desktop. We enter the MYSQL-CC, the username "ROOT" password is empty, the default port number is "3306", the host name added to "localhost." After determining, the right health chooses the connection. Now we can manipulate our MySQL database.


(figure II) Click to prevent large


The purpose of using EJBS is to manipulate the underlying data in an object's way, so we have to build our own underlying data first. As shown in figure three, right click on the left side of the MYSQL-CC "databases", select "new", named "MyTest."


(Figure III)

Based on the new database, we are building a data table. As shown in Figure four, add two fields "id", "context", the type is "varchar", save the time named "MYEJB".


(Figure IV)

Open the data table just built to add a few data, "id" is 1,2,3, "context" and "id" should be "time", "blank", "talk".

4. It's time for our application Server JBoss to show up. Download Jboss3.2.3 from JBoss's SourceForge subproject (http://sourceforge.net/projects/jboss/). Extract it into a folder, such as D:\worktools\Jboss3.2.3. Copy the Mysql_ds.xml under the \DOCS\EXAMPLES\JCA to the \server\default\deploy and edit it with Notepad. There are several modifications, as shown in Figure five:


(Figure V)

After you save it, rename it to "Mytest-ds.xml," which is the data source we use to write the EJB.

We need to use MySQL's Java driver to connect our MySQL database with JBoss. We still have to download the mysql-connector-java-3.0.11-stable from the MySQL homepage. Unzip the compressed package, extract mysql-connector-java-3.0.11-stable-bin.jar from it, and put it into the \server\default\lib directory under the JBoss directory, and rename the file to Mysql.jar.

5. At this point, we can do the actual development. Perhaps you would ask, what is the use of editing our program, difficult to use Windows from the Notepad? Of course! But a variety of cumbersome, repetitive operation is not conducive to the growth of our novice. What we need is an integrated development tool (IED) to help us handle some low-level operations, and quickly write a usable system to improve our confidence in learning Java EE. When we get to know more about Java, we go back and write each of the required files with a text-editing tool, and then compile and deploy to quickly improve our level.

Here I recommend an excellent development tool, which is the eclipse mentioned earlier. In fact, it can be imagined as a very friendly framework, by installing a variety of compatible plug-ins to meet our diverse development needs. You know, it is the background of IBM, but for us more important is that it is completely free, we can even develop their own plug-ins!

Download Eclipse2.1 from the Eclipse home page (http://www.eclipse.org) and download Lomboz2.1.3 to www.objectlearn.org, a powerful eclipse plug-in in the development of Java EE. First unzip Eclipse and Lomboz, The COM.OBJECTLEARN.JDT.J2EE and com.objectlearn.jdt.j2ee.editors that are generated by the Lomboz compression pack are then copied to the \plugins folder in the Eclipse home directory. Run Eclipse, select "Windos"-> "Customize Perspective ... "。 As shown in Figure six:

Click to prevent large


Expand all nodes, select all the options for Lomboz, and then click OK. (Figure VI) Select "Window"-> "preference". Click Lomboz to select the \lib\tools.jar in your JDK directory in the JDK tolls. jar and click Apply. Because our application server chooses JBoss to support thermal deployment, make sure the restart server after Depoly option is not selected. As shown in Figure seven, expand the Lomboz option on the left, and select the server Definition. In the server types we chose JBoss 3.2.x. The application Server directoty and classpath variable the same choice of JBoss's home directory, and click Apply.


(Figure Seven) click to enlarge


or in "window"-> "preference", expand the Java class, and select New project in source and output folder to change it to folders, as shown in Figure eight.


(Figure Eight)


Click Apply, and then click OK.

Shout ~ Take a breath, so far we have to develop the Java EE system required for all the software installed configuration. Have a cup of tea and immediately develop our first ejb!.

Next page



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.