Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Search:
How to create a J2ME MIDP RSS Reader application with NetBeans 4.0
Contributed by Tommi Laukkanen as part of the Win With NetBeans comptetition This tutorial will show you how to create a J2ME MIDP RSS Reader application with NetBeans 4.0. With RSS Reader you can read RSS feeds with your mobile device. This application is designed to work with MIDP 1.0 so it is also compatible with older devices. In case you are new to RSS, it stands for Really Simple Syndication. RSS is a lightweight XML format designed for sharing headlines and other content like blogs and news. You can for example get the latest NetBeans.org news as a RSS feed from here. Here are some screenshots of this application in action:
Learning Trails
Basic Java Programming Java GUIs and Project Matisse Web Applications Java EE Applications Mobile Applications SOA Applications and UML NetBeans Modules and Rich-Client Applications
Launch icon
Bookmarks list
Loading form
Headers list
Topic form
Creating new mobile application project with NetBeans 4.0 Configuring your NetBeans 4.0 project to allow the usage of 3rd party libraries (eg. kXML 2) Using obfuscator to reduce distributable jar file's size with NetBeans 4.0 Running mobile application on emulator with NetBeans 4.0
RssFeed.java, The code for the RSS feed class RssItem.java, The code for the RSS feed item class RssFeedParser.java, The code for the RSS feed parser class Settings.java, The code for the settings utility class RssReaderMIDlet.java, The code for the MIDlet class
This tutorial won't deeply explain the the functionality of each class. You can aquire source files here.
Requirements
You must have NetBeans IDE 4.0 and the NetBeans Mobility Pack 4.0 installed before you can start J2ME MIDP development. See the J2ME MIDP Development Download page for instructions on downloading and installing the complete environment. You also need to download kXML mobile class library. The latest version of the library on time of writing was 2.1.9. You can download the latest kXML release here. Download the kxml2-min. jar to any folder on your computer.
3. Under Project Name, type RSS Reader. 4. Change the Project Location to any folder on your computer. 5. Select Set as Main Project checkbox 6. Unselect Create Hello MIDlet checkbox 7. Click Finish. Now the project node in Projects window should look like this:
Create new Java Packages for source files and application icon
1. Right-click the RSS Reader project node in Projects window and select New > Java Package
2. Under Package Name, type RssReader. 3. Click Finish. 4. Repeat the previous actions and add icons package Now you have requred packages for the source code files and the application icons.
2. Select Application Descriptor > Attributes. 3. Select MIDlet-Vendor line under General Attributes list and click Edit. 4. Under Value, type your own name. 5. Close the edit window by clicking OK button. Now we are going to add a reference to kXML library that you have downloaded on your computer. 6. Select Build > Libraries & Resources. 7. Click Add Jar/Zip. 8. Browse to downloaded kxml2-min.jar file Now you have added the reference to kXML library and you can use the kXML parser in your application.
If you wouldn't have the source code ready, then you would use New > Java Class or New > Midlet features and then write your own code.
2. Right-click the RSS Reader project node in Projects window and select Properties. 3. Select Application Descriptor > MIDlets. 4. Click Add. The NetBeans IDE is smart enough to fill up all the fields as you only need to select the icon that you want your application to have. 5. Under MIDlet Icon, select /icons/rss.png.
1. Press F11 to build your project. Alternatively you could select Build > Build Main Project from the main menu. 2. Right-click RSS_Reader.jar on the Files window and select Properties.
3. Right-click RSS Reader project node and select Properties. 4. Select Build > Obfuscating 5. Slide the Obfuscation Level to maximum value (=High). 6. Click OK button. 7. Rebuild the application pressing F11 8. Right-click RSS_Reader.jar on the Files window and select Properties. Take a notice that jar file's size is reduced to 15kb bytes.
As the memory usage in smaller mobile devices is a critical issue, therefore the obfuscating is very important part of the mobile application development. We have now saved almost 10 kb memory only by changing Obfuscator settings on our NetBeans IDE.
Launch icon
Bookmarks list
Loading form
Headers list
Topic form
The end
Conclusion and development ideas
This concludes the J2ME MIDP RSS Reader tutorial. You may now easily continue on developing this application by adding new features. You could for example add a support for Atom XML feeds. Please keep me informed what ever you do with this code :)
Shop
SiteMap
About Us
Contact
Legal
By use of this website, you agree to the NetBeans Policies and Terms of Use