Home > Articles > Programming > Java

  • Print
  • + Share This
From the author of

Network Programming with J2SE Versus J2ME

For those who have developed network applications using Java 2 Standard Edition, network programming is fairly simple and straightforward; J2SE provides network libraries that are rich in functionality. Approximately 60 classes are available in the java.io package to support file input and output, and approximately 20 classes are available in the java.net package to support networking.

However, most of the classes in these two packages are designed to support traditional computer systems with enough CPU power, sufficient memory, and sufficient disk storage. The total static size of these class files is approximately 200 kilobytes. These packages are too big to fit in the typical wireless device, which has very limited computing power and a total memory and storage budget of a few hundred kilobytes.

Size is not the only issue when dealing with wireless devices. Java 2 Micro Edition needs to support a variety of mobile devices. The networking and file I/O capability varies significantly from one wireless device to another, so the requirements for networking and file I/O libraries are very different. For example, some wireless carriers use packet-switched networks, whereas others use circuit-switched networks. The difference between the two networks requires two different communication abstractions in Java libraries: datagram-based communication for packet-switched networks and socket-based communication for circuit-switched networks. Vendors that support datagram-based communication may not be interested in supporting socket-based connections and vice versa.

NOTE

A circuit-switched network creates telecommunication connections by setting up an end-to-end circuit. The circuit remains open for the duration of the communication, and a fixed share of network resources is tied up; no one else can use those resources until the connection is closed. The main advantage of a circuit-switched network is that performance guarantees can be offered.

A packet-switched network creates telecommunication connections by breaking up the information to be sent into packets of bytes, sending them along a network with other information streams, and reassembling the original information flow at the other end. The main advantage of a packet-switched network is that it makes very efficient use of fixed capacity. The disadvantage is that the quality of service of an information channel cannot be guaranteed.

The file I/O for wireless devices falls into a similar situation. These file accesses are highly device specific and require different implementations. Due to strict memory limitations, the vendors who support one type of file I/O mechanism generally do not want to support another.

The networking in J2ME has to be very flexible to support a variety of devices and has to be very device specific at the same time. To meet these challenges, the Generic Connection framework is first introduced in the CLDC. The idea of the Generic Connection framework is to define the abstractions of the networking and file I/O as generally as possible to support a broad range of handheld devices, and leave the actual implementations of these abstractions to individual device manufacturers. These abstractions are defined as Java interfaces. The device manufacturers choose which one to implement in their MIDP implementations or PDAP implementations based on the actual device capabilities.

  • + Share This
  • 🔖 Save To Your Account