![]() |
What would life be like if you could browse the World Wide Web and download information with your telephone, obtain high-quality entertainment through your television, or download travel information with a mobile computer? Not only would you have fast and easy access to all the information you could possibly need, but the way you live, play, work, learn, shop, and interact with other people would change too.
The PersonalJava platform is designed for network-connectable consumer products in the areas of communication, entertainment, and mobile computing; and could possibly change the way we live and relate as dramatically as the invention of the telephone in 1876 changed the way people lived and related in the nineteenth and twentieth centuries.
Today's potential for leading-edge electronic consumer applications is unlimited, and the many advantages in the PersonalJava platform make it easy to turn innovative ideas into real consumer products. This article takes a look at why.
The PersonalJava platform is a subset of the Java Development Kit (JDK), and PersonalJava code runs seamlessly on the Java platform. In addition, PersonalJava introduces new features specific to consumer products such as PersonalAWT, and some new APIs such as Timing. Where appropriate, PersonalJava features will be propagated to the Java platform to maintain upward compatibility.
The PersonalJava platform is specifically designed for small-scale and network connectable consumer products in set-top boxes, handheld computers, web phones, smart phones, automotive navigation equipment, information appliances, and game consoles--to name a few. Device developers, content developers, and service providers for PersonalJava products will find the PersonalJava platform an effective way to infiltrate the lucrative consumer market while gaining great savings in time and costs.
The full suite of customized development tools for device and application developers
is described on the tools web page. In addition to the standard compiler and
interpreter commands
(java
and javac
) there are special tools to estimate
and control an application's resource requirements, check whether a group of
class files meets the desired specifications, and reduce the aggregate
size of class files. Of particular interest is JavaCheck, which you can run
on any Java applet to ensure it does not make use of any APIs that
are not available on the PersonalJava platform.
The PersonalJava
API specification is a subset of the JDK 1.1 API specification
with the addition of the Timing APIs and the java.awt.isDoubleBuffered
method. The next three sections give a more detailed look at the differences
between the PersonalJava 1.0 platform and JDK 1.1.
JDK 1.1 Packages: The following JDK 1.1 packages are included in the PersonalJava platform to provide the core Java capabilities. Some of these packages are included in the PersonalJava platform without change from JDK 1.1, while others have been subsetted by removing functionality not appropriate for consumer products. Some of the changes are noted below; refer to the API specification for more detailed information.
Package | Description |
---|---|
java.applet | APIunchanged |
java.awt | API subsetted |
java.awt.datatransfer | API unchanged |
java.awt.event | API unchanged |
java.awt.image | API unchanged |
java.awt.peer | API subsetted. |
java.beans | API unchanged |
java.io | API subsetted |
java.lang | API unchanged |
java.lang.reflect | API unchanged |
java.net | Two minor changes |
java.util | API subsetted |
java.util.zip | API subsetted |
Other JDK 1.1 packages are either optional or unsupported in the PersonalJava platform.
Optional packages are not required in a PersonalJava implementation and applets cannot assume that any of an optional package's classes are present.
Unsupported packages raise
java.lang.UnsupportedOperationException
when included in a PersonalJava
implementation. Unsupported methods in supported classes raise
java.lang.UnsupportedOperationException
when used in a PersonalJava
implementation, and java.lang.NoClassDefFoundError
is raised when a
required package is not included in a PersonalJava implementation.
PersonalJava AWT: The PersonalJava abstract window toolkit (AWT) consists of a carefully chosen subset of functionality derived from the full Java AWT. The subset was chosen to match the primary target end-user of PersonalJava devices--the technically unsophisticated consumer who is not familiar with the user interfaces used on desktop systems. Some of the features from the full Java AWT that are not required in the core Personal Java AWT include scroll bars, menus, and multiple overlapping windows.
The java.awt.Component.isDoubleBuffered
method available in the
PersonalJava platform returns a Boolean that indicates if the platform an
application is running on supports double buffering. If True, all drawing done inside
the paint
and update
methods is automatically double
buffered. If false and you need nonflickering updates, you must explicitly create an
offscreen image, draw into it, and use the drawImage
method to display
it. Be aware that this approach can use a lot of memory and might fail on some
devices.
Internationalization: The PersonalJava platform includes optional Internationalization (I18N) support. To reduce space and memory requirements, the PersonalJava 1.1 platform will let you choose exactly which languages you want to support.
Timing APIs: The PersonalJava platform includes the com.sun.util
package that provides timing APIs for implementing timers that do not need an
additional callback thread.
The main issues in consumer device application development involve human factors and hardware concerns such as how to write a user-friendly interface for mouseless devices or displays that support only 4 or 16 colors.
The style guide on the PersonalJava web page provides a lot of good advice for these and other consumer product issues to help you successfully design and develop applications for the consumer market. The following code examples (taken from the style guide) give you some coding tips to help you avoid common problems.
Repainting Components: This first example is an animation applet with a timer thread implementation that calls the repaint method to get an immediate call to the update method. This approach is better than having the thread update itself several times a second because it ensures components are updated correctly to avoid visual defects that can make a consumer applet unusable.
import java.awt.*; import java.applet.*; public class Anim extends Applet implements Runnable { Image[] images; int curFrame = 0; Thread timerThread = null; public void init() { images = new Image[2]; images[0] = getImage(getCodeBase(), "image1.gif"); images[1] = getImage(getCodeBase(), "image2.gif"); if(timerThread == null) { timerThread = new Thread(this, "Timer"); timerThread.start(); } } public void paint(Graphics g) { update(g); } public void update(Graphics g) { g.drawImage(images[curFrame], 0, 0, this); } public void stop() { timerThread = null; } public void run() { Thread myThread = Thread.currentThread(); while(timerThread == Thread.currentThread()) { try { Thread.sleep(300); } catch (InterruptedException ex) { return; } int nextFrame = curFrame + 1; if (nextFrame == images.length) { nextFrame = 0; } curFrame = nextFrame; repaint(); } } public void destroy() { for (int i = 0; i < images.length; i++) { images[i].flush(); images[i] = null; } images = null; } }
Input Preferences: The input device typically provides a way for the user to
select the current component. The PesonalJava platform provides input preference
interfaces that let you decide how users navigate among and
interact with interface components. The input preferences in the PersonalJava
com.sun.util
package are as follows:
Class MyButton
represents a button on a screen and must handle up and
down clicks, and the selection state. It implements the
ActionInputPreferred
input preference as follows:
public class MyButton extends Canvas implements ActionInputPreferred { public MyButton(Image down, Image up, Image disabled) { MouseListener mouseListener = new MouseAdapter() { public void mousePressed(MouseEvent e) { ...//User clicked button. // Do something. } public void mouseReleased( MouseEvent e) { ...// User released button. } public void MouseEntered(MouseEvent e) { ...// User has navigated here. } public void mouseExited(MouseEvent e) { ...// User has naviagated away. } }; addMouseListener(mouseListener); } ... }
The PersonalJava platform is ideal for consumer applications running in set-top boxes, handheld computers, web phones, smart phones, automotive navigation equipment, information appliances, and game consoles. PersonalJava 1.0 programming is just like programming with JDK 1.1 with minor differences--a few new APIs and tools, and functionality customized for consumer applications.
Consumer applications written for the PersonalJava platform can run on any consumer device to which the platform is ported, and manufacturers and service providers can add updates or new features by way of the network or Web. With the PersonalJava platform, device manufacturers can create portable device software and offer a standard platform to content providers who might develop content and applications on desktops to distribute across PersonalJava-enabled consumer devices regardless of the underlying operating system and CPU architecture.
Personal WebAccess is another related JavaSoft product. Personal WebAccess: Personal WebAccess is a customizable and compact web browser for the PersonalJava platform. Consumers running PersonalJava applications such as screenphones, home entertainment systems, and information appliances can access the Web and retrieve information using Personal WebAccess.
© 1994-2005 Sun Microsystems, Inc.