Develop J2EE applications using Eclipse
content:
I. Download, Install and Configure II. Using Eclipse Development Web Application III, use Eclipse to develop EJB four, summarize the reference information About the author Appendix: jboss320.server
There is also a Java area:
Teaching tools and product code and components all articles practical skills
---- Jun, integrated Eclipse, Lomboz and JBoss Jiang Wei (jiangww@lenovo.com) Development Engineer of Lenovo Group Software Design Center Eclipse is a very excellent integrated development environment, this open source project under IBM support After a period of development is perfect, it has been familiar with the majority of Java developers. The emergence of Eclipse provides Java developers with free use of powerful Java IDE, through integrated large amounts of Plugin, Eclipse's functionality can be expanded to support a variety of different applications. Lomboz is a free Eclipse Plugin, which integrates many Java application servers, J2EE components, and web applications to Eclipse, which helps Java developers build, test, deploy J2EE applications. JBoss is an open source, powerful Java application server, is also a Java application server that is most popular in Java developers, and is awarded the 2002 Best Application Server by Java World's editors. The downloaded quantity so far in 2003 has exceeded 15 million times. First, download, installation, and configuration 1. Eclipse download and installation First need to install JDK, you can download the latest version and install it up to Sun's website. Then go to www.eclipse.org to download the latest version of Eclipse, the current latest version is 2.1. After downloading, unfailed to the directory you want, such as D: / Eclipse, running Eclipse.exe directly, automatically looks for JDK when you run, and complete the appropriate configuration, then enter the main interface of Eclipse. About Eclipse's basic usage, developerWorks, Eclipse websites, and Eclipse's random documents are described in detail, which is not described in detail. 2. JBoss download, installation JBoss's current latest version is 3.2.1, but I think this version has some problems, there will be some JAR packages when the server is started, causing the happening of WARN and Error. So I recommend download 3.0.7, or I can download JBoss version 3.0.7 of Tomcat 4.1.24. After downloading, we assume that JBoss_home is the main directory of JBoss, execute jboss_home / bin / run.bat, launched the JBoss server. Generally, it will be started for about 1 minute. 3. Lomboz download, installation, and configuration Lomboz's current version is 2.1, we assume that the primary directory of Eclipse is eclipse_home, download it below the Eclipse_home / plugins folder, so there is more com.Objectlearn below this folder. .jdt.j2ee folder. Then start the Eclipse, the Customize Perspective dialog box will automatically appear. If you do not appear, you can also display this dialog by menu "Window-> Customize Perspective, as shown below:
Expand File-> New, select all options related to Lomboz; expand Window-> Show View, select Lomboz J2EE View; Expand Other, select Lomboz Actions. Confirm OK. Below you want to make Lomboz configuration: First, open the Properties dialog, make sure the settings in Java-> New Project: Then in the Lomboz property, make sure you set the following:
Finally, set the server properties. Lomboz pre-defines the settings of commonly used Java servers, which are placed under the Eclipse_home / plugins / com.objectlearn.jdt.j2ee / servers folder, you can use the text editor to manually modify (unless you use the server is not in Lomboz In the default server, otherwise I don't recommend you to do this), or set in the Eclipse's Properties dialog box, the process is very simple, as shown below:
Remember After each modification, you must click Apply. The above figure is the setting under the Properties tag. The ClassPath label does not need to be changed under the label (Note: If you don't listen to the advice of my article, I use the version of JBoss3.2.0, which may need to manually add more JAR package. This is physical activity, some troubles. I don't know if this is a JBoss problem, and I will mention it below.). Through the above three steps, Lomboz's support and JBoss configuration are completed. You can enter the second part of the article "Using Eclipse Development Web Application". Note: a. If the server is not in the default server; in the eclipse_home / plugins / com.objectlearn.jdt.j2ee / servers folder, create a file named Server file, then edit Server with the text editor according to the existing Server file file. After establishing a new Server file, you can also make the appropriate settings in the property page of Lomboz. b. If you use the JBoss 3.2.0 version. Open Window> Preferences> Lomboz> ServerDefinitions, select your server, then select the ClassPath tab, add the following JAR package to Server Library: jboss_home / lib / concurrent.jar
JBoss_Home /Lib/boss-system.jar
JBoss_Home / Server/default/lib/jboss.jar
JBoss_Home / Server/default/lib/jpl-pattern.jar
JBoss_Home / Server/default/lib/jpl-util.jar
JBoss_Home / Server/default/lib/jnpserver.jar
JBoss_Home / Server/default/lib/jboss-transaction.jar
The entire content in my jboss320.server file is presented in the last part of this article. Second, using the Eclipse development web application First, open file-> new-> Lomboz J2EE Project, create a J2EE Project called TestJ2ee. Click Next, default various settings, click Next, go to the next dialog, add the configured server in TargeTed Server, as shown below: New web modules and EJB modules are newly created in Web Modules and EJB Modules, in this case We named myWeb and MyEJB, and then click Finish. In this way, the framework of a J2EE project is automatically generated. Below under the MyWeb module, two JSP files are automatically generated: index.jsp and error.jsp, and the configuration file below the web-INF file. We can add your own JSP files and servlets on this basis, and then build project. Click on the Lomboz J2EE Project Outline on the toolbar of Eclipse:
In this way, Lomboz J2EE VIEW appears on Eclipse, as shown below:
Since I have already deployed another web server: Tomcat, the two servers it binds in this module, the red tag next to JBoss 3.0 all indicates that it is the default server. You can choose to change the default server by right-clicking the web module, as shown below:
After selecting the server, right-click the server in Lomboz J2EE VIEW, select Run Server, wait until the server is started, and right-click the web module, select Deploy Module, which completes the deployment of the web module on the server. Open the IE browser, type http://127.0.0.1:8080/Myweb, you can see the web application developed. Here is a point where Tomcat is used as a web server, if the web module needs to be redeployed, you must restart the Tomcat server, and JBoss doesn't do this. Note: When you start the JBoss server from Eclipse, you encountered this problem:
Error Occurred During Initialization Of VM
Java / Lang / NoclassDeffounderror: Java / Lang / Object
Generally encountered this problem, it may be because JRE is not set, please expand Java-> Installed JRES in the Preference dialog box in Eclipse, see if JRE is set; then open the developed project properties dialog, see Java In the library of Build Path, there is JRE SYSTEM LIBRARY, no words, click Add Library, add JRE SYSTEM LIBRARY.
Third, using Eclipse development EJB In the second part "Using Eclipse Development Web Application", we have added a MYEJB to the EJB module in the TestJ2ee J2EE project. Below we add a session bean to the MyEJB module through Lomboz EJB CREATION WIZARD. Click File-> New-> Lomboz EJB CREATION WIZARD, or right-click the MyEJB module, select New-> Lomboz EJB CREATION WIZARD, show the following dialog: Create a named myejb in com.dino.testj2ee.myejb STATELESS session bean. After completion, under the SRC folder of the TestJ2ee project, a file called myejbbean.java appeared, right-click this file, select New-> Lomboz EJB Method Wizard, you can add various methods to this EJB. I added a HelloWorld method and returned a string type. As shown below:
Then, you need to add myejb Session Bean to the MYEJB. This module is: right-click Myejb.java, select Lomboz J2EE ... -> Add Ejb To Module, select MyEJB, OK. Right-click the MyEJB module, select Lombozj2ee ... -> Generate EJB Classes, which automatically generates the following files below the EJBSRC directory: MyEJBHOME.JAVA
Myejbrome.java
Myejblocalhome.java
Myejblocal.java
Myejbsession.java (MyEJBSESSION EXTENDS MyEJBBEAN)
MyEJBUTIL.JAVA
After BUILD Project, the module is automatically packaged. Then you can deploy the EJB module according to the steps of deploying the web module. Finally, we build an app to test EJB. Open a dialog box by file-> new-> lomboz ejb test client wizard, fill in the picture below:
After completion, TestMyejb.java has been generated below the src directory, and the test code is added to the TestBean method:
System.out.println (MyBean.helloworld ());
If the current JBoss server is already launched, and the MYEJB module has been deployed, the testmyejb is executed, and it will be displayed on the Console window:
HEHE, I can Deploy EJB by Eclipse!
IV. Summary Through the above introduction, we learned that Lomboz makes Eclipse development J2EE applications very simple, and Eclipse, Lomboz, JBoss tools are free and open source projects, so such a combination is for Java developers. More attractive. For developing complex J2EE applications, the above introduction may not be comprehensive enough, I hope everyone will experience the process of doing the project, then summarize the experience to develop it in developerWorks. Reference:
Www.eclipse.org Eclipse's official website; www.jboss.org jboss's official website; www.objectlearn.com Lomboz website, the top of Lomboz. Eclipse In Action: a guide for Web Developers, by David Gallardo, Ed Burnette and Robert McGOvern, Manning Publications. A good book developed using Eclipse. JBoss 3.0: Quick Start Guide, by jboss group. A good book about JBOSS. About the author Jiang Wei, is the development engineer of Lenovo Group Software Design Center, passionate about J2EE and Web service technology. When you are free time, you like to read your computer books and frequently patronize each Java forum; on the evening of the weekend, you will generally watch the live broadcast in front of the TV. Address: Pioneer Building, No. 7 Kondow Road, Shangdi Information Industry Base, Beijing, China Post Code: 100085. You can contact him with E-mail: jiangww@lenovo.com. Appendix: jboss320.server EjBModules = "true" WebModules = "true" Earmodules = "true"> TYPE = "Directory" default = "d: /jboss-3.2.0" /> TYPE = "string" default = "127.0.0.1" /> TYPE = "string" default = "8080" /> TYPE = "string" default = "jboss32" /> TYPE = "Directory" default = "d: /jboss-3.2.0" /> serverclasspath> clientclasspath> serverdefinition>