Using netbeans for development (2): transferring programs to mobile phones

Source: Internet
Author: User
Tags netbeans
First, we learned that writing a mobile phone program is actually very simple. However, many people may not quite understand how to transfer the program to their mobile phones. If you don't believe it, try it. Whether you use a data cable or infrared Bluetooth, there is no way to get the programs on the computer to run on the mobile phone, nor to get the games on other people's mobile phones to run on their own mobile phones (normal data transmission is acceptable, that is, the program is not acceptable ). I once saw a lot of games on other people's mobile phones and tried to transfer them.

Why? This is because the Java program must go through an installation process before running on the mobile phone, and this installation process is completed through your mobile phone's AMS (application management software, however, this AMS can only be downloaded from the Internet for installation. After understanding this truth, it is much easier to transfer the program to a mobile phone. Isn't it necessary to download the program from the Internet? Which of the following is NOT a website builder? Make it easy to create a tomcat. We can even build a mobile app download website to start a business. This kind of download server is called OTA server and OTA is over the air. Is it intuitive? Isn't wireless Internet access like a mobile phone downloaded through air?

To create an OTA server, you first need to understand the structure of the j2's program. After the project of the j2's program is generated, it should be composed of two files, one. JAR file and. JAD file ,. the jar file is naturally a resource file that contains all of our Java programs and various images and music. a jad file is a text file that contains the description of our program. When installing the program, AMS uses this. JAD file to learn some information about our program. In the previous article, the saved directory of the project we created is D:/Java/projects/myfirstmobileapplication. Under the DIST directory of this directory, we can see two files: myfirstmobileapplication. jar and myfirstmobileapplication. Jad.

When we open the Tomcat server, we are too lazy to create a web application. Just use the default Tomcat application and copy the above two files to the webapps/root directory in the Tomcat directory, then, create a simple WML file download in the directory. WML:

<? XML version = "1.0"?>
<! Doctype WML public "-// wapforum // dtd wml 1.1 // en"
Http://www.wapforum.org/DTD/wml_1.1.xml>

<WML>
<Card Title = "welcome" id = "Main">
<P> Download Software: </P>
<P align = "Left"> <a href = "myfirstmobileapplication. Jad"> </a> </P>
</Card>
</WML>

After editing the WML file, we also need to check whether the conf/Web. xml file in the Tomcat directory contains the following lines:

<Mime-mapping>
<Extension> Jad </extension>
<Mime-type> text/vnd. Sun. IMO. app-Descriptor </mime-type>
</Mime-mapping>
<Mime-mapping>
<Extension> jar </extension>
<Mime-type> application/Java-archive </mime-type>
</Mime-mapping>

If not, add them. However, Tomcat of the latest version is usually available.

OK. You can use your mobile phone to download our program. But remember two points:
1. mobile Internet access requires money. For example, here, China Mobile charges 3 cents for every download of 1 K. Don't underestimate it. 1 m is 30 yuan, and you can see how much money you have to throw into the water. However, you can also customize the monthly subscription service, for example, 5 yuan for 10 m or 20 yuan for 50 M. However, if you really download every program to your mobile phone for testing, I think this is not enough.
2. Your server must be accessible. This means that you must have a domain name and a server to be rented. This also requires money. However, if you use a simulator to access it on your own machine, you only need to access http: // localhost: 8080/download. WML.

Therefore, we still use a simulator to demonstrate how to install the software. The mobile phone simulator program that comes with mobilepack 5.5.1 is called emulator and is one of the components of wtk2.5.1. Using it in netbeans IDE is easy to run projects, but it is a bit troublesome to open the software separately. In the netbeans installation directory, there is a wtk251-win.zip file in the cmdity7.3/emulators-instdirectory, extract the file to the wtk251-win folder, you can see the following files in the wtk251-win/emulator/bin directory:
  

Run ktoolbar.exe. the application interface is as follows:
  

Note that the "project" menu is gray at this time. You need to open a project to use the project menu. Select "Run Through Ota" in this menu, for example:
  

The simulator is displayed. The following operations are completed in the simulator. In, select the "application" menu:
  

Then, select "install application". The URL input interface is displayed, as shown in Figure 5. Enter the download. WML address we just wrote:
  

Start download:
  

After the download is complete, AMS will extract the Jad connection included in it. We will select the program to be installed:
  

Confirm installation:
  

After the installation is complete, a program myfirstmidlet is added to our application list. The effect of running this program has been paxed in the previous article, and it will not be repeated here:
  

Finally, in emulator, it comes with many sample projects. Let's take a look. The following figure shows the running effect of the demo3d project. It seems that writing 3D games on mobile phones is not impossible.
  

 

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.