Java and flex Study Notes (2) -- Build a flex and javaee development environment in myeclipse8.6

Source: Internet
Author: User

After a day of exploration, I finally completed the development environment for building the flex and javaee projects in myeclipse8.6. The development environment is as follows:


1. the flex version is Flex 4.


2. The myeclipse version is 8.6, and the integrated flex development tool is adobefash builder 4.5.


3. JDK 1.6


4. tomcat version 6.0


Now we are building a development environment.


First, create a javaweb project. This is very simple and I will not go into details here, as shown below:




Decompress the downloaded blazeds (you can also download it here) and copy the META-INF and WEB-INF folders to the webroot of the above project to overwrite the original two folders of the same name, as shown below:




Open the server and deploy this project. The project will be published to the webapps folder of Tomcat. Next, add the flex project based on this project. Note: Do not disable the Tomcat server during this process.


Right-click the project and choose Add/change project type --> Add flex project type, as shown below:




The Select flex SDK selection box will pop up. My default flex4.5 is displayed:




Click "Next". The page is displayed as follows:




My configuration is shown above, where:


Application Server Type selects Java,


Use Remote Object Access Service selects blazeds,


Rootfolder selects the release path of the javaandflexdemo project.


The rooturl is the project path released by javaandflexdemo.


Contexroot indicates the container path,


Output Folder refers to the position where flex exists after being compiled. I chose SWF.


Click "Validate configuration", if everything is reasonable, you will be prompted "the Web root folder and root URL are valid". If not, you may have problems with the configuration.


Now, click "finish" to complete the project construction. After the build is complete, an error will be prompted. The solution is to right-click the problem under the problems option and select "recreate HTML templates", as shown below:


Because the mxml file generated by this project is in the src directory by default and stored in the same directory as the Java source file, it is not easy to manage the project. You can change this directory by right-clicking the project, select properties. In the pop-up attribute box, click the flex build path tab and change "src" in main source folder to "flex_src". This changes the storage location of the Flex file, at the same time, the output of this tab
The position where the folder URL input mxml file is compiled to the server is as follows:




Click "OK" and a "felx_src" main directory will be added to the project to move the original mxml file to this directory. Then, Flex is integrated with javaee.

 

Run the following code to test whether the project is successfully built and create a Java common class helloworld. Java under the src directory:


Package com. yqsn. Test; public class helloworld {public stringsayhello (string name) {return "hello," + name ;}}

Add the following code to the WEB-INF under the webroot/remoting-config.xml/felx directory:


<destination id="hw">       <properties>           <source>com.yqsn.test.HelloWorld</source>       </properties>    </destination>   

Edit the javaandflexdemo. mxml file. The Code is as follows:


<? Xmlversion = "1.0" encoding = "UTF-8"?> <S: Application xmlns: FX = "http://ns.adobe.com/mxml/2009" xmlns: S = "Library: // ns.adobe.com/flex/spark" xmlns: MX = "Library: // ns.adobe.com/flex/mx "minwidth =" 955 "minheight =" 600 "> <FX: SCRIPT> <! [CDATA [import MX. controls. alert; import MX. RPC. events. faultevent; import MX. RPC. events. resultevent; protected function send_clickhandler (Event: mouseevent): void {// todoauto-generated method stub hello. sayhello (mess. text);} protected function hello_resulthandler (Event: resultevent): void {// todoauto-generated method stub alert. show (event. result as string, "succeeded");} protected function hello_faultha Ndler (Event: faultevent): void {// todoauto-generated method stub alert. show (event. fault. message, "failed");}]> </FX: SCRIPT> <FX: declarations> <! -- Place non-visualelements (e.g ., services, value objects) Here --> <s: remoteobject id = "hello" Destination = "HW" result = "hello_resulthandler (event)" fault = "hello_faulthandler (Event) "/> </FX: declarations> <s: Label x =" 68 "Y =" 110 "fontsize =" 16 "text =" enter your name: <s: textinput x = "209" Y = "103" id = "mess"/> <s: button x = "381" Y = "104" label = "send" fontsize = "16" id = "send" Click = "send_clickhandler (event)"/> </s: application>

 

Now, deploy the project. In the address bar of the browser, enter http: // localhost: 8000/javaandflexdemo/SWF/javaandflexdemo.html. The page is as follows:




Enter your name and click send. The page is as follows:




OK. This proves that the project has been built perfectly and will be learned more core technologies in the future!


The complete structure of this project is attached as follows:




Original article, reprint please indicate the source: http://www.dianfusoft.com/showDetail.action? ArticleID = 130405013502
For more original articles, visit: http://www.dianfusoft.com/




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.