Wednesday, November 19, 2003

SUN: PC+ Monitor + Color Printer Under $300

After huge China deal, SUN seems to be on roll. AOL started started selling PC (With Monitor, Color Printer, Star Office rebranded as AOL Office) for $299.
This could be huge. The only gotcha is that you have to commit to use AOL for a year($23.90 per Month). If this offer becomes successful you find more and more home users using Star Office. I am sure J2SE1.4 is preinstalled on these machines (Though not mentioned anywhere).
Find the offer from AOL here:
Star Office PC
An interview with Java Desktop System team is published at OS News.

Wednesday, November 12, 2003

J2ME: MIDP2.0 phone from Motorola

Motorola i730 is available in us markets. Key features:
J2ME Support : MIDP 2.0 (JSR 118),Mobile Media(JSR 135), WMA (JSR 120)
OEM Support: Motorola LWT, Look And Feel, Polyphonic MIDI, WAV, AU, Vibrator, Lighting, Motion JPEG, Still image capture, Location API, Phonebook, Datebook, External display, Call Receive and Initiation, Recent calls, File I/O, Serial port, Crypto, Digital Camer, Java Menu MIDlet icon, RF enabling, Alpha blending, Secure file connection, Voicenote, 3D
Heap Size: 1.15 MB
Midlet Storage: >2MB (installed MIDlet space), >2MB (file storage), Recommended Maximum jar file size is 500KB. Now serious business applications and Games are possible on i730.
Max Sockets: TCP: 16,HTTP: 8,UDP: 24 (21 according to developer guide and 24 according to Device specs).
65K Color Display: Vibrant display with enhanced clarity allows you to customize your screen with downloadable wallpapers, adjustable color palettes, and choice of three font sizes.
Concurrency: Supports execution of upto 3 MIDlets at the same time. (Ofcourse only one MIDlet can be in foreground).

Another cool innovative feature is Airplane Mode where you can turn off network connection and use programs, games, voice record, and datebook. Phone will display “Airplane Mode” while in use and display “Service Restricted Airplane Mode On”. The nice thing about i88S and i730 from Motorola is that you can query your location from your phone(using J2ME) without paying a single cent.

Compared to this my Motorola i88s looks so dumb and ugly. I wish I can exchange my phone :-)
i730 Handset

Wednesday, October 29, 2003

M$: Another entry to hall of shame

Image is self explanatory:

Saturday, October 04, 2003

Directories are Java source file package names

After reading this blog by Gregg Wonderly and some of the comments posted at the blog I decided to write this blog entry.
For a long time I used to think directories are not Java source file package names because Chapter 7 of Java language specification said so. Also many a times(For any product that you work on for long time) maintaining directories as Java source file package names is a pain. Imagine you are developing a product called javamagic. You are working for a oraganization which has several suborganizations and with several products for each sub organization. If your java source files must be in a directory tree mirroring the package name, your source directory would typically look something like this:

Having this structure is pain and sounds dumb because you know com/javaswamy/jone/javamagic is always constant and there is absolutely no need to maintian this filesystem hierarchy as you know what you are working on. If possible a simple hierarchy like this would be what everyone likes to have:

This is easy to navigate and presents developer view of the code.

Now lets get back to reality. Though Java Language Specification doesn't impose the restiction of Directories are Java source file package names, JavaDoc does. JavaDoc tool faq states "If your classes do not all belong to the unnamed package, you must put them in directories named after the packages.". So if you need to generate javadocs for your project and use JavaDoc tool to generate the documentation, Directories are Java source file package names.

Like many other java programmers, I would love to see JavaDoc team solve these problems that exist since JDK1.1 days:
1. Directories are Java source file package names.
2. Deprecation warning is suppressed if the compilation unit containing the deprecation is being compiled at the same time as the compilation unit using the deprecated class or member.

Wednesday, October 01, 2003

Office: OpenOffice.org 1.1 released

OpenOffice.org announced first major update to OpenOffice. 1.1 is now final and English version is available for download on Windows, Solaris and Linux. I have been using 1.0.x versions and 1.1 RC's for a while. With every update OpenOffice is getting better and better and better compatability with M$ Office. OpenOffice is now the only office suite on my home machine.
The two new major features for me in 1.1 update are export to PDF format from OpenOffice.org Writer and export to Macromedia Flash format (.swf) from OpenOffice.org Impress. Support for export to PDF got better with every update.
Checkout my blog archive for the month 2003_09 exported to PDF from Writer:Kumar Mettu's Blog.pdf. The only data lost from saved html file is Hyperlinks.
Here is a simple presentation exported to Macromedia Flash format (.swf):


Check out OpenOffice.org XML Essentials book online.

Tuesday, September 30, 2003

J2ME: Get Weather Forecasts Free

Weather on Demand is one of the most common applications of SMS. Few of weather service examples are:

1. Weather alerts from Verizon .
2. Weather Network and TELUS Mobility's On Demand Weather service and
3. Weather.com's Radar on Mobile Phones.
With a simple MIDlet you can get Weather forcasts free on your phone. US government provides free weather forecasts here. Note that the weather forecasts are not as high quality as commercial services. The simple MIDlet here displays weather at SF(modify the URL to point to your city):




001 import java.io.IOException;
002 import java.io.InputStream;
003 
004 import javax.microedition.io.Connector;
005 import javax.microedition.io.StreamConnection;
006 import javax.microedition.lcdui.Command;
007 import javax.microedition.lcdui.CommandListener;
008 import javax.microedition.lcdui.Display;
009 import javax.microedition.lcdui.Displayable;
010 import javax.microedition.lcdui.Form;
011 import javax.microedition.midlet.MIDlet;
012 
013 
014 /**
015  * MIDlet to display weather forecast for SF.
016  *
017  @author Kumar Mettu
018  @version 1.0
019  *
020  */
021 public class Weather extends MIDlet implements CommandListener {
022 
023     private Display display;
024     //Exit command.
025     private Command  exitCommand = new Command"Exit", Command.SCREEN, );
026     //SF Weather URL.
027     private static final String SF_URL =
028         "http://weather.noaa.gov/pub/data/forecasts/city/ca/san_francisco.txt";
029 
030     /**
031      * Weather MIDlet constructor.
032      */
033     public Weather() {
034        display = Display.getDisplay(this);
035     }
036 
037     /**
038      * This will be invoked when we start the MIDlet.
039      * Display the downloaded data. If an error occurs while downloading
040      * the data display the error to user.
041      *
042      */
043     public void startApp() {
044         try {
045             getViaStreamConnection();
046         catch (IOException e) {
047             Form forecast = new Form("Error Downloading");
048             forecast.append(e.getMessage());
049             forecast.addCommandexitCommand );
050             forecast.setCommandListenerthis );
051             display.setCurrent(forecast);       
052        }
053     }
054 
055     /**
056      * Pause, discontinue ....
057      */
058     public void pauseApp() {
059 
060     }
061 
062     /**
063      * Destroy. Cleanup everything.
064      */
065     public void destroyApp(boolean unconditional) {
066     }
067 
068     /**
069      * Download the weather and display it.
070      *
071      @throws IOException when IO Error occurs while downloading
072      *  data from URL.
073      */
074     private void getViaStreamConnection() throws IOException {
075         StreamConnection sc = null;
076         InputStream in = null;
077         StringBuffer b = new StringBuffer();
078 
079         try {
080           sc = (StreamConnection)Connector.open(SF_URL);
081           in = sc.openInputStream();
082           int ch;
083           while ((ch = in.read()) != -1) {
084              b.append((charch);
085           }
086 
087         finally {
088            if (in != null) {
089               in.close();
090            }
091            if (sc != null) {
092               sc.close();
093            }
094         }
095 
096         Form forecast = new Form("Weather at SF");
097         forecast.append(b.toString());
098         forecast.addCommandexitCommand );
099         forecast.setCommandListenerthis );
100         display.setCurrent(forecast);
101     }
102 
103     /**
104      * Indicates that a command event has occurred on Displayable d.
105      @param c - a Command object identifying the command.
106      @param d - the Displayable on which this event has occurred.
107      */
108     public void commandActionCommand c, Displayable d ){
109         if (c == exitCommand){
110             exit();
111         }
112     }
113 
114   /**
115    * Distroy app when exit button is used.
116    */
117     private void exit(){
118         destroyApp(true);
119         notifyDestroyed();
120     }    
121 
122 }



You can download Weather.jar and Weather.jad directly. Tested on my i88s. Here is the screen snapshot of Motorola i88s simulator:



This can be further extended to support features like:
1. Select the city where you want weather forcast(using kxml)
2. If your phone supports GPS( like my Motorola i88s), you can display weather forecasts for your current location.