Saturday, November 15, 2008

Is Sun's JavaFX RIA platform a RIA?

It's been a long hype cycle for Sun's RIA strategy. JavaFx was first touted in 2007 and a public beta took almost a year to reach the hands of developers. While the official release is scheduled anytime between now and December, I can't help feel that Sun has lost momentum in a space it should own.

Earlier this year Jonathan Schwartz, CEO of Sun Microsystems, claimed that Java has always been an RIA platform. Technically, he is correct -- Java is and was "write once, run anywhere (that has the Java virtual machine)" platform. For Sun, client-side Java never really took off for Web apps and to a large extent technology like Flash, and later AJAX, stole the show. Although Java at first stumbled with performance issues, it was on par with these technologies but never seem to marry the designer tools and the developer back-end know-how efficiently.

Fast-forward to 2008 and Adobe is the clear leader in the RIA world and its investment in technologies like Flex and Air are pulling traditional Java developers away from aging technologies like Swing. On top of this Microsoft has stuck its RIA pole in the ground with Silverlight and is looking to drum up a large developer community with their technology stack. Microsoft is catching up fast.

Sun is running behind. For a company that itself boasts penetration rates of its virtual machine to be 85% of desktops, 90% of handsets, and many home entertainment devices, the progress seems slow-going.

Sun needs to be seen as innovating in this area. Technology decisions are made on progressive platforms which attract significant investment in time and resources by the company that produces it. It's simply not good enough to leave Java quietly chugging along in the corner, even if it is open source.

If Sun can marry the client-side potential of JavaFX to the server-side it will be a huge boost to the company, the Java community, and related vendors who are powered by Java technology. If not, Java certainly won't go away, but it's not going to attract a great deal of new business.

The stakes will be even higher in the embedded market for Sun, an area in which it has strong marketshare. With JavaFX for mobile devices due out in early to mid 2009 the company will need to show its platform is up to speed compared to stiff competition from Google's Java-powered Android phones, Microsoft's mobile platform, the iPhone, and other next-generation phones.

Can Sun do it? Maybe it can. Will Java live on? Of course it will. With or without Sun in the picture Java will still be innovated by the likes of IBM, Google, and Oracle. The technology just needs a clear steward to take it to the next level.

What do you think of Sun's efforts with JavaFX? Leave your thoughts in the comments section below.

Sunday, November 9, 2008

JavaFX

JavaFX is a family of products for creating so called Rich Internet Applications, web applications that have the features and functionality of traditional desktop applications, including interactive multimedia applications. The JavaFX products can build applications for desktop, mobile, TV and other platforms.

JavaFX consists of JavaFX Script and JavaFX Mobile.

The primary component of JavaFX is JavaFX Script, a declarative language, intended to make Swing easier to use for interface programmers or visual designers who might be more familiar with scripting languages. In JavaFX Script, the structure of the programming code is supposed to closely matche the actual layout of the GUI.

JavaFX Mobile is a Java operating system for mobile devices, including PDAs, smartphones and feature phones. It features a Java SE and Java ME implementation running on top of a Linux kernel.

JavaFX Mobile

JavaFX Mobile is a complete mobile operating and application

environment built around Java and Linux open source technologies. It is a complete, fully integrated Java software system for advanced mobile devices designed to enable developers to author rich, high-impact content and network-based services. Built around open and standards-based technologies, JavaFX Mobile enables control and flexibility for the mobile ecosystem.

Being centralized around Java technologies, JavaFX Mobile software system provides a greater scalability and portability, speed time-to-market, and enhances the consistency of applications and services. Additionally, it also provides a support for Java ME applications and other standard Java APIs which enables a broad range of new and existing Java applications.

It is like the networking in your hand. It is based on open standards. JavaFX Mobile runs on all mobile phones with Java support e.g. Nokia N800.

JavaFX Mobile, Sun's software system for mobile devices, is available via OEM (i.e. Original equipment manufacturers) license to carriers, handset manufacturers and others seeking a branded relationship with consumers. Through OEM multiple companies can simplify and accelerate the development of powerful standardized software systems to leverage the power across a wide range of consumer devices.

Additionally, It allows content creators to create rich media content without relying on developers, allowing the drag and drop of desktop and mobile content, which is not possible with any other RIA.

Get Ready for Dynamic Interactive Content on Any Device: It is unpredictable to guess what devices or platforms the end user is using; however with JavaFX, you don't have to worry about the things. JavaFX Mobile uses industry standard technologies--this means that applications built with JavaFX can run on a wide range of Java-enabled devices, and content providers can add them to their devices quickly. JavaFX Mobile includes the latest standards, like the Mobile Services Architecture, set of device APIs, which allows developers to have a rich set of highly portable capabilities.

End users always look for an exciting and dynamic content on the web and expect a better interactive experience with web services. JavaFX helps in delivering visually compelling applications, such as maps and mashups, video, audio, and pictures, that is standardize across cell phones, TVs, and more.

Reduced Integration Costs with Expanded Opportunities: Implementation of the majority of the solution in Java, including middleware and resident applications, JavaFX Mobile reduces integration costs, improves device software consistency, and enables device manufactures to provide new offerings with substantially faster time-to-market.

JavaFX Mobile Architecture:

JavaFX Mobile streamlines the environment and reduces reliance on underlying technologies by providing a complete middleware and application stack implemented in Java.

JavaFX Script

JavaFX Script is a scripting language designed by Sun Microsystems, forming part of the JavaFX family of technologies on the Java Platform. JavaFX targets the Rich Internet Application domain (competing with Adobe Flex and Microsoft Silverlight), specializing in rapid development of visually rich applications for the desktop and mobile markets. JavaFX Script works with integrated development environments like NetBeans and Eclipse. JavaFX is released under the GNU General Public License, via the Sun sponsored OpenJFX project,

Google Gmail for Mobile 2.0 Adds J2ME Support


Google Inc on Thursday launched a new version of its Gmail for Mobile. Google Gmail offers J2ME support which includes mobile devices such as NOkia N95 and RIM BlackBerry mobile phones. The online Google Gmail application has better performance and smoother scrolling.
Google Gmail for Mobile 2.0 has been released. The updated Google Gmail application offers improved performance and smoother scrolling. Gmail users with multiple accounts can now switch between them without using different applications to view messages.

Google Inc on Thursday released version 2 of its Google Gmail for Mobile application. Google Gmail has several nice features including support for offline access for the first time.

Google Gmail for Mobile 2.0 adds new support for J2ME-supported mobile phones. The Nokia N95 and BlackBerry mobile devices are some of the phones that use J2ME.

The new Gmail for Mobile application offers improved performance and speed. It also offerssmoother scrolling and fixes the "freeze" bug. Some mobile phones were freezing up while scrolling in Gmail.

"We re-architected the entire client to push all the processing to the background, greatly improve the client-side caching scheme and optimize every bottleneck piece of code we came across," Google software engineer, Derek Phillips, said in a statement.

The offline support lets users read and compose new emails offline. This feature also works when there's no 3G signal.

The mobile application now supports multiple accounts for Gmail. Users can also switch between accounts without using different applications to view messages. Gmail for Mobile 2.0 also offers support for smart phones that have a QWERTY keyboard. This feature lets users create shortcut keys for Gmail.

Sunday, October 26, 2008

Debugging Java Code in the CVM

CVM supports the JVMDI, so you can connect a JPDA debugger to it without involving a
separate debug proxy of the type used by KVM. However, before you can start debugging,
you need to do two things:

1. Build the CVM with the CVM_DEBUG and CVM_JVMDI options to the make
command set to true.

2. Build the library libjdwp, which contains the native code that implements the Java
Debug Wire Protocol (JDWP). This protocol allows debuggers to connect to the VM
over a socket or using shared memory.

You can build libjdwp using the following commands:

cd $CDC/ext/jpda/build/linux
make

This creates the library and writes it to the file $CDC/jdk_build/linux/lib/i386/libjdwp.so.

Starting CVM for debugging requires quite a long command line:

cvm -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=5000
-Xbootclasspath:$CDC/build/linux/lib/foundation.jar -Dsun.boot.library.
path=$CDC/jdk_build/linux/lib/i386 -Djava.class.path=$EXAMPLES/src ora.
ch7.CVMProperties

The options used here are as follows:

-Xdebug

Starts the VM in debug mode. When this option is used, the VM suspends operation
before entering the main( ) method of the initial application class.

-Xrunjdwp

Tells the VM to use JDWP for debugging. This option requires several parameters,
separated from it by a colon and from each other by commas, that specify how the
debugger will connect to the VM. In this case, the parameters supplied are as follows:

transport=dt_socket
Specifies that the debugger will connect over a socket.

server=y
Tells JDWP to take on the server role. The debugger itself acts as the client.

address=5000
Specifies the port number that the server should use to listen for a connection from the
debugger client.

-Xbootclasspath

Specifies the location of VM's boot classes, in this case the set of core and Foundation
Profile classes that have not been prelinked into the VM.

-Dsun.boot.library.path

Gives the directory in which the JWDP implementation library (libjdwp.so for Linux)
can be found.

-Djava.class.path

Specifies the locations to be searched for application classes.

Once the CVM has started, it will suspend and wait for a debugger to connect to it on the port
specified in the -Xrunjdwp argument. If you have an IDE that supports remote JPDA
debugging (such as Forte for Java), you can use it to perform source- level debugging. Alternatively, you can use the command-line tool jdb, which is part of the J2SE SDK. To connect using jdb, you need to specify the socket address on which the VM is listening and the location at which the source code for the application's classes can be found:

jdb -attach localhost:5000 -sourcepath $EXAMPLES/src

Here, jdb and the CVM are assumed to be on the same machine, but this need not be the case.
Following connection, you need to use the step command to force the VM to enter the
main( ) method. From here, you can use jdb commands to set breakpoints, list the source
code around the line currently being executed, inspect and modify objects and fields, and so
on.

By default, when you use the -Xdebug argument, the JVMDI support in the VM starts at the
same time as the VM itself and suspends execution until a debugger connects to it. However,
you can choose to have JVMDI defer its initialization until an exception of a named type or an
uncaught exception is thrown. The latter case is often the type of error that you would like to
use a debugger to investigate, but starting the VM in debug usually causes it to execute byte
codes more slowly. Using this feature, you can run the VM at full speed until the exception
occurs.

The options that control the point at which the debugging features initialize is part of the -
Xrunjdwp argument. The following command:

cvm -Xdebug -Xrunjdwp:transport=dt_
socket,server=y,address=5000,onuncaught=y -Xbootclasspath:$CDC/build/
linux/lib/foundation.jar -Dsun.boot.library.path=$CDC/jdk_build/linux/
lib/i386 -Djava.class.path=$EXAMPLES/src ora.ch7.CVMException

adds the onuncaught option with value y, which delays initialization of the JVMDI until an
uncaught exception occurs. The class ora.ch7.CVMException used here waits for 10
seconds, then deliberately causes a NullPointerException that it does not catch, at which
point the debug facilities initialize and the VM is suspended. You can now start jdb to analyze
the problem.

Alternatively, if you simply want to start debugging when a NullPointerException occurs,
use the onthrow option, which requires the class name of the exception to wait for:

cvm -Xdebug -Xrunjdwp:transport=dt_
socket,server=y,address=5000,onthrow=java.lang.NullPointerException
-Xbootclasspath:$CDC/build/linux/lib/foundation.jar -Dsun.boot.library.
path=$CDC/jdk_build/linux/lib/i386 -Djava.class.path=$EXAMPLES/src
ora.ch7.CVMException


Finally, you can use the launch option to cause a command to be executed when the VM
debug facilities initialize. This option requires the name of the command, which should be
either an absolute path or the name of an executable on your search path (i.e., included in the
PATH variable for Linux). When it is started, the program receives the transport name and
address used by the debugger as arguments -- that is, it is effectively run with arguments like
this:

name dt_socket 5000

One way to make use of this is to create a script that starts jdb when the condition that starts
the JVMDI support occurs, like this:

#!/bin/sh
jdb -attach localhost:$2 -sourcepath $EXAMPLES/src

If you put these lines into a file called startdbg.sh (in a directory included in your PATH
variable) and make it executable (using a command like chmod +x startdbg.sh), the
following command:

cvm -Xdebug -Xrunjdwp:transport=dt_
socket,server=y,address=5000,onthrow=java.lang.
NullPointerException,launch=startdbg.sh -Xbootclasspath:$CDC/build/
linux/lib/foundation.jar -Dsun.boot.library.path=$CDC/jdk_build/linux/
lib/i386 -Djava.class.path=$EXAMPLES/src ora.ch7.CVMException

runs the VM until a NullPointerException occurs, at which point it initializes the JVMDI
code, suspends bytecode execution, and runs your script. This results in jdb starting and
connecting to the VM, using the port number that is passed as the second argument to the
script.

Saturday, October 4, 2008

MIDP GUI Programming

User interface requirements for handheld devices are different from those for desktop computers. For example, the display size of handheld devices is smaller, and input devices do not always include pointing tools such as a mouse or pen input. For these reasons, you cannot follow the same user-interface programming guidelines for applications running on handheld devices that you can on desktop computers.

The CLDC itself does not define any GUI functionality. Instead, the official GUI classes for the J2ME are included in profiles such as the MIDP and are defined by the Java Community Process (JCP). You'll note that the GUI classes included in the MIDP are not based on the Abstract Window Toolkit (AWT).

Click Here To Read More

Basic I/O

This article the Java platform classes used for basic I/O. It focuses primarily on I/O Streams, a powerful concept that greatly simplifies I/O operations. The article also looks at serialization, which lets a program write whole objects out to streams and read them back again. Then the article looks at some file system operations, including random access files. Finally, it touches briefly on the advanced features of the New I/O API. Most of the classes covered are in the java.io package.

Click Here To Read More

Using and Programming Generics in J2SE 5.0

 A Java collection is a flexible data structure that can hold heterogeneous objects where the elements may have any reference type. It is your responsibility, however, to keep track of what types of objects your collections contain. As an example, consider adding an int to a collection; since you cannot have collections of primitive data types you must convert the int to the corresponding reference type (i.e. Integer) before storing it in the collection. Now, when the element is extracted from the collection an Object is returned that must be cast to an Integer in order to ensure type safety. All this makes Java programs unnecessarily hard to read and maintain, and are more likely to fail with runtime errors.
If the compiler could keep track of the element type, you do not need to keep track of what collections you have and the need for casting would be eliminated. This would make programs easier to read and maintain, and less likely to fail at runtime. J2SE 5.0 has added a new core language feature known as generics (also known as parameterized types), that provides compile-time type safety for collections and eliminate the drudgery of casting. The effort of adding generics to Java is led by Sun Microsystems as JSR 14 under the Java Community Process (JCP).
Generics are one of the most frequently requested language extensions to Java, and they have been finally added in J2SE 5.0. This article provides an introduction to programming with generics.
The Need for Generics
The motivation for adding generics to the Java programming language stems from the lack of information about a collection's element type, the need for developers to keep track of what type of elements collections contain, and the need for casts all over the place. Using generics, a collection is no longer treated as a list of Object references, but you would be able to differentiate between a collection of references to Integers and collection of references to Bytes. A collection with a generic type has a type parameter that specifies the element type to be stored in the collection.

Click Here To Read More