Use NetBeans for J2ME Development (ii): Transfer the program to the phone

Source: Internet
Author: User
Tags tomcat tomcat server netbeans

In the previous article, we have seen that writing a mobile phone program is actually very simple. But a lot of people probably don't quite understand how to move a program to a cell phone, do not believe you try, whether you are using the data line, or with infrared Bluetooth, can not get the computer program to run on the phone, there is no way to put other people on the phone game to get their mobile phone running (the transmission of ordinary data can be, is not the program). I once was to see other people's mobile phone has a lot of games, want to transfer over, how to try not.

Why is that? This is because the Java program has to go through an installation process before it runs on the hand, and the installation process is done through your mobile's AMS (Application Management software), which can only be installed from an online download program. Understand this truth, then transfer the program to the mobile phone is much simpler, not just to download from the Internet? Which one of us is not a master of site building? It's easy to get a tomcat. We can even build a mobile program to download the site as a way to start a business. Such a download server professional called Ota server, Ota, is over the air, is not very intuitive, such as mobile phones such as wireless Internet access is not through the air to download it?

Build an OTA server, first of all to understand the structure of the J2ME program, J2ME program after the project is generated, should be composed of two files, a. jar file and a. jad file, the. jar file Needless to say, it is naturally a resource file containing all of our Java programs and all kinds of pictures and music. and the. jad file is a text file that contains the descriptive information of our program. AMS is using this. jad file to understand some of our program's information when installing the program. In the previous article, we created the project to save the directory for D:\Java\Projects\MyFirstMobileApplication, in this directory under the Dist directory, You can see two files: Myfirstmobileapplication.jar and Myfirstmobileapplication.jad

With the Tomcat server open, we're also lazy to build a Web application and use Tomcat's default application. Okay, copy the top two files to the Webapps\root directory of the Tomcat directory, and then, Then create a simple WML file download.wml in this directory, as follows:

<?xml version="1.0"?>
   <!DOCTYPE wml PUBLIC"-//WAPFORUM//DTDWML1.1//EN"
   "http://www.wapforum.org/DTD/wml_1.1.xml">

   <wml>
   <cardtitle="welcome" id="main">
   <p>下载软件:</p>
   <palign="left"><a href="MyFirstMobileApplication.jad"></a></p>
   </card>
   </wml>

After editing this WML file, we have to examine one thing, which is to open the Conf\web.xml file in the Tomcat directory to see if there are any of the following lines:

  <mime-mapping>
       <extension>jad</extension>
       <mime-type>text/vnd.sun.j2me.app-descriptor</mime-type>
     </mime-mapping>
     <mime-mapping>
       <extension>jar</extension>
       <mime-type>application/java-archive</mime-type>
     </mime-mapping>

If not, add them in. But the most recent version of Tomcat is available.

OK, the following can be used to download our program on the phone. But please remember two points:

1. Mobile Internet is for money, such as we here, the price of Chinese mobile is 1k per download 3 cents, do not underestimate Ah, 1M is 30 yuan Ah, see how much money you have to throw in the water. But you can also customize the monthly service, 5 yuan 10M or 20 yuan 50M, but if you really every program to download more to the mobile phone test, I think this monthly is not enough.

2. Your server must be able to be accessed, which means you have to have a domain name, but also to rent a server, which is also a money. Instead of using an emulator to access it on your own machine, you can only access the HTTP://LOCALHOST:8080/DOWNLOAD.WML.

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.