Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Commercial applications with Java

Commercial applications with Java

Tutorial Details:

Building a commercial-quality Web application in Java
Building a commercial-quality Web application in Java
By: By Rich Kadel
A small company explains what it learned while developing
software to support Netscape's AppFoundry program
f you wonder how well Java holds up as a development language for commercial-quality apps, you'll likely want to hear about our recent experience. As a participant in the Netscape AppFoundry program -- which was unveiled September 9, see the Netscape press release , for details -- our company, DTAI, created a business application designed to let intranet users view and update dynamic company organization charts via a Web browser. We created this full-blown application exclusively in Java, and in the process learned quite a bit about the strengths and limitations of the language. What follows is an account of our project and the lessons we learned.
DTAI's interactive Org Chart application is unique among the AppFoundry applications in that it is the only one developed exclusively in Java. Most of the other AppFoundry applications were developed primarily in HTML and JavaScript. DTAI chose Java because of the need for a high-degree of interactivity and graphics, including drag-and-drop capabilities, and drill-down navigation of complex organizational diagrams.
Our assignment
DTAI got involved with the AppFoundry project early and secured an assignment. Our task: develop a Company Org Chart application exclusively with Java and JavaScript, and use LiveWire Pro where possible. See the sidebar " Working with Netscape " for complete background on the project and its parameters.
Challenges
The AppFoundry schedule was aggressive, to say the least. For most, development began in mid June. The first Alpha delivery was scheduled for mid-July, and the final product was due in mid-August. Moreover, developers were asked to take advantage of the new features in Netscape's most recent releases and beta software. These products inevitably were not proven and often inadequately documented.
DTAI spent much of the first two or three weeks trying to find out what new products like LiveWire Pro and Netscape Enterprise Server would do for us. Initially, we had decided to save the Org Chart data files to a relational database running on the server. LiveWire Pro provides solutions to help you write server-side JavaScript to connect to a database. We had to scrap this initial design, however, when we learned that LiveWire Pro did not support a Java-to-database connection directly. (JavaSoft's JDBC should eventually solve this sort of problem. (See the May 1996 JavaWorld article " Integrating Databases with Java via JDBC " for details.)
After examining our database requirements, we determined that the database for the Org Chart would be simple enough to implement using an ad-hoc, flat-file solution. We decided to write a Java-based database server for the Org Chart. We developed a Java application that would listen for Socket connections from clients (Java applets running in a browser), and then respond to requests to read and write records within a file resident on the Web server's file system. (We used the generic client-server classes I wrote about in the September 1996 JavaWorld article, " Generic client-server classes .") This worked pretty well. We used Java's file IO classes and, for the most part, the application was portable to multiple operating systems, including Unix, Windows 95, and NT.
Executing the server
The database server application should be running constantly -- like an HTTP server, for example -- but this kind of operation usually requires that system files be modified to start the application at boot-up. And if the application dies unexpectedly, it typically requires intervention by the system administrator. This seemed like too much hassle for such a simple application, so we took a different approach:
First, the applet would attempt to connect to the database server, assuming the server was already running.
If the server was not already running, the applet would attempt to load a CGI program on the server, using a Java URL and the openStream function to cause the program to be executed.
The CGI program would set up the environment and then execute the server.
The applet would then attempt to connect to the server, trying once per second until some maximum number of attempts is reached. (The connection usually succeeds within one attempt.)
One trick to this was that the CGI program had to finish executing, or the URL connection in the browser would not complete and the application would hang. The solution for Unix was to start the Java database server application in a background process. No problem.
Enter Windows NT
We had another requirement. We had to support server solutions for both Unix (initially Solaris) and Windows NT. The biggest hurdle related to the NT port that we had to overcome was in "backgrounding" the database process. With Unix, we took for granted the fact that background processes and foreground processes are handled identically by the operating system. Windows NT, however, does not treat background processes as "first class citizens." There are no tools for backgrounding a process. No simple shell symbols, or function calls. We dug out the Advanced Windows textbooks and put together a small program (included with the Org Chart distribution) that takes a command line with arguments and executes that command in a new process "without a console" (that is, in the background).
It worked, but still had the downside that there are no tools included with the standard Windows NT distribution to locate and/or kill the process if necessary. The Windows NT Resource Kit (sold separately) supplies some Unix equivalents to "ps" to find the process, and "kill" to terminate it. Not nearly as good as their Unix counterparts, but they do the job. Third-party vendors also supply Unix commands and shells for NT. Rebooting the system also works. :-)
The CGI program also had to be rewritten for NT. In fact, we never could get Netscape Enterprise Server to execute a ".CGI" file using the PERL.EXE program. And Perl is not as portable as some people claim. Many of the functions that I had used in the Unix version (including "fork" and "exec" of course) simply were not implemented in the Win32 version. That's one of the reasons I believe Java still has a good chance to replace Perl as the language of choice for CGI programming (not to mention the fact that Perl script is completely incomprehensible).
Netscape server-side Java
Netscape is starting to support Java as a CGI alternative. Netscape Enterprise Server supports Java plug-in applications, known as Netscape Server Applets. We took a look at this technology as another potential solution to the Java-based database application, running it directly within the server. We had no problems running the simple example Java server applets, but when we tried configuring our database application as a server applet, the HTTP daemon on Windows NT crashed. Additional perusal of some of the Netscape-based newsgroups on Java confirmed that others had similar problems configuring complex Java applications as server applets. This feature sounds promising, but probably has a way to go before it is ready for prime time.
Write once, run anyhow
As required, our final version of the Org Chart ran successfully on Windows NT and Solaris servers, and Windows 95 clients. Unfortunately (and this is probably not news to most Java enthusiasts), the AWT components don't behave identically on all platforms. Worse yet, some implementations of the Java Virtual Machine (JVM) and/or the Java library are more robust than others. Windows 95 is now my platform of choice for Java development because it gets the most attention by Java tool developers. Under Windows 95, I can develop and test with a high degree of confidence that my Java application is going to run as designed.
The Org Chart application makes extensive use of the Java library. It pushes the envelope of Java implementations. Although it runs flawlessly (at least from what I have seen) on Windows 95, as a standalone application, or within Netscape 3.0, it can have problems on other platforms. The Org Chart uses pop-up dialog windows for viewing and entering employee information, for instance. The applet works fairly well under HP and Solaris, but Motif-based Java implementations like these still have poor implementations of the Dialog window object, causing distracting screen flashes, and window navigation problems. Netscape reported that the applet portion of the Org Chart would not even run under MacOS, and ran incredibly slowly on a Silicon Graphics machine (a machine not usually associated with the phrase "a snail's pace").
Here is a word of caution: Inconsistencies in the graphical user interface implementations will be problematic if you don't test your applet on all platforms. For instance, in Windows 95 and NT, the AWT button always has a gray background. In one example, we set the background color of the panel encompassing several buttons to black. We left the foreground color black (the default) because black contrasts well with the gray button backgrounds. On Unix, however, the buttons inherit the background color from the parent panel, making the text unreadable in this scenario.
I can't promise that there are no bugs, but the Org Chart applet does not appear to use any questionable features or techniques. I'm convinced that there are not enough "large" Java applications out there yet to stretch the testing procedures for current JVM and Java library implementations. Hopefully, more applets like ours, with source code if possible, will start to be made available to Netscape, Microsoft, Sun, and others so that we can eventually stop coding workarounds to their bugs. Org Chart can run as a standalone application, as well as an applet. This should be encouraging to PDA an


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Commercial applications with Java

View Tutorial:
Commercial applications with Java

Related Tutorials:

Integrating Databases
Integrating Databases
 
Commercial applications with Java
Commercial applications with Java
 
Will Big Blue eclipse the Java tools market?
Will Big Blue eclipse the Java tools market?
 
Java scripting languages: Which is right for you?
Java scripting languages: Which is right for you?
 
Let the mobile games begin, Part 2
Let the mobile games begin, Part 2
 
Java tools reign supreme - JavaWorld celebrates the leading Java tools
Java tools reign supreme - JavaWorld celebrates the leading Java tools
 
Advanced Installer for Java
Advanced Installer for Java The quick, simple and powerful msi authoring tool Advanced Installer is a Windows Installer authoring tool which enables developers and system administrators to easily build reliable MSI packages that meet the latest Micr
 
Java Floating License Enforcer Developer Package
Java Floating License Enforcer for Java Developer Package
 
Using Java Classes in Windows Batch Files
Using Java Classes in Windows Batch Files - a simple approach for system admin Although Java is an ideal language for implementing rich GUI applications, it is equally well-suited for the development of small console-based programs that, in turn, are p
 
nexB - IT assets and applications autodiscovery and management
Open By Design The nexB vision is to build business applications that are Open by Design(tm). Open by Design means that the design for business applications is as open as the source code. In fact, all phases of software development need to be open from d
 
Welcome to the Tonic Look & Feel.
Welcome to the Tonic Look & Feel. This pluggable look and feel is a free substitute for the default native look and feel of Swing, 'Metal', distributed under the GNU Lesser General Public License.
 
Create Intelligent E-mail Filters with JavaMail and Classifier4j
Create Intelligent E-mail Filters with JavaMail and Classifier4j Tired of the limitations and annoying false positives with commercial spam filters? Classifier4J is an open source Java library that will let you build custom applications that read e-mails
 
Using Timers in J2EE Applications
Using Timers in J2EE Applications Job scheduling is nothing new--most enterprise applications require the scheduling of tasks and activities. For example, your application may need a timer service to run a business process once a day, or to clean up a te
 
100 % java open-source cryptographic software libraries.
Cryptixtm is an international volunteer effort to produce robust, open-source cryptographic software libraries. Cryptix products are free, both for commercial and non-commercial use and are being used by developers all over the world. Development is ...
 
Game Canvas Basics
Introduces the MIDP 2.0 GameCanvas class and the game loop concept. Required reading for all aspiring "first person shooter" developers.
 
Sun Java System Access Manager Activities with Actuate Enterprise Reporting Platform:
An Integration Story This paper describes the procedure for integrating Actuate 7 with Sun Java System Access Manager to generate reports that reflect the activities on Access Manager. Also discussed are enhancements and workarounds for known bugs.
 
What is Persistence Framework?
What is Persistence Framework? What is Persistence Framework? A persistence framework moves the program data in its most natural form (in memory objects) to and from a permanent data store the database. The persistence framework manages the
 
WAP Toolkits Motorola - Mobile ADK 1.1 Nokia - WAP Toolkit
WAP Toolkits Motorola - Mobile ADK 1.1 Nokia - WAP Toolkit Tutorial WAP Toolkits T o develop any WAP application you have to download software essential for development. Although you can write and test your codes through our site for learning
 
News: World Records Broken with Sun Studio 10 Software and the Solaris 10 OS
Sun submits new performance world record for Sun Studio 10 compilers and the Solaris 10 operating system.
 
Solaris 10 OS Released
The Solaris 10 Operating System is now officially a production release. Download it today at no cost and see how Solaris software can make a difference for you.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.