02
Sat, Nov
2 New Articles

Java 2: Third Time's the Charm

Java
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

One of the really great things about having a custom-built Java implementation for the AS/400 is that the environment can be optimized to take advantage of the unique architecture of the machine. IBM’s Java implementation, implemented as it is “below the machine interface (MI),” does just that. There is a downside, however: Patience is required. Much of the rest of the computing world has been enjoying their Java 2, formerly known as Java Development Kit (JDK) 1.2, implementation since December 1998; we AS/400 programmers are still waiting. AS/400 implementation of the Java 2 specification will be available as a PTF later this year. (The Java Virtual Machine, or JVM, that comes with V4R4 is compliant with JDK 1.1.7.) According to MC’s Monday Morning AS/400 Update, the Java 2 PTF should have arrived alongside the DB2 Universal Database PTF sometime in September.

Fortunately, the specification for the JVM did not change significantly from JDK
1.1.x to Java 2. Nonetheless, Java 2 is really a significant leap for the language: There’s more functionality, much tighter security, and better enterprise integration available. The upgrade from JDK 1.1.x to Java 2 was termed a “library and performance” release by Sun, meaning that the bulk of the new stuff is in the API. In this article, I give you a quick peek at some of the new features available in Java 2.

The most hyped component of Java 2 is, without a doubt, the Java Foundation Classes (JFC). JFC is the set of new Java 2 services for GUI programming. The components of JFC had been available for more than a year before Java 2 was announced; they were (and still are) available as a widely distributed beta called Swing. JFC is Swing (more on this in a moment) plus drag-and-drop plus Java2D plus accessibility plus some other miscellaneous services, such as keyboard navigation and undo. In other words, Swing is in JFC, but JFC is not Swing.

Swing is a rewrite of the Abstract Window Toolkit (AWT). The AWT was a “lowest common denominator” set of GUI classes. What this means is if a function wasn’t available on one of the platforms supported by Java, it wasn’t available on any platform. Furthermore, the widgets (buttons, frames, etc.) didn’t look or behave identically on all platforms, because the ultimate responsibility for drawing the widget and processing events

JFC

fell to the operating system. (Widget is a generally accepted term for a software component.) Even worse, because of the operating system reliance, the AWT widgets weren’t extensible. For instance, if you wanted to design a button with an icon on it, you had to build it yourself.

Swing fixes these problems by rewriting all the widgets for you from scratch, all in Java. There are now “J” versions of all the basic widgets: JButton, JFrame, JList, and so on. In addition to the basic widgets, Swing adds several new ones. JTree is a hierarchical list similar to Windows Explorer. JTable is a row/column spreadsheet with cool features such as resizable and movable columns. JScrollPane allows you to scroll any container. Finally, JToolbar is a floatable panel that contains little icons representing actions.

Swing also changes the way in which you manage the GUI. All Swing widgets use a Model-View-Controller (MVC) architecture, making it possible, for instance, to use your own data objects as the store for a JTable rather than store copies of your data inside the JTable itself. MVC also allows a “pluggable look and feel” (PLaF), which makes a Swing app look and feel just like a Windows, a Mac, a Motif, or some other app. The JDK download includes samples of various PLaFs for you to try.

Security in Java 2 is much improved from that in JDK 1.1.x. In fact, the JDK “Summary of New Features” (java.sun.com/products/ jdk/1.2/docs/relnotes/features.html) on Sun’s Web site lists the security enhancements first. Clearly, this is an area that had come under scrutiny as companies investigated Java. In a time when companies fear Internet security breaches and individuals fear computer viruses, it’s great to know that Java 2’s security features are superior to those of any other language available for Internet applications.

Java 2’s security model augments the sandbox with a much more flexible system based on permissions and identity. Without augmenting the default sandbox security features, Java applets run in a highly restricted mode. Security in the virtual machine is defined by the Policy, which provides a way to control the powers of pieces of code. Java Security Manager now delegates its work to the Policy object. Policy, in turn, consults a policy file to decide whether sensitive operations are allowed. Policy grants particular Permissions to the program based on a combination of where the code came from (the code base) and by whom the code was written (the code signature). You can extend the Permissions model by adding your own application-specific security checks.

Policies can be defined in a policy file or by using the new policytool application. This new security model allows for a great range of possibilities. For example, a user may decide to allow applets to save files to particular directories if the applets come from a trusted source. The level of control available is akin to AS/400 data access rights, where some users get only READ access to data, some get READ and UPDATE access, and some get full rights (READ, ADD, UPDATE, and DELETE).

Nothing is free, however, and the improved security in Java 2 is no exception. Expect a performance hit for the new JVM, due to the tighter security, from 10 percent to 30 percent, depending on whose estimate you choose to believe.

The Java Database Connectivity (JDBC) API included in Java 2 (which is now called JDBC 2.0) has several key features. Among them is the ability to have a true cursor when examining a result set. This feature allows you to move forward and backward as well as to modify entries. JDBC 2.0 also supports the SQL3 data types supported by the AS/400’s database: binary large objects (BLOBs), character large objects (CLOBs), and user-defined data types (UDTs). Of course, this new support is available only in the new JDBC drivers. The old JDBC drivers continue to work, however. By the way, IBM’s Java Toolbox for the AS/400 (which is bundled with OS/400) has included a JDBC 2.0 driver since V4R4. For more information on JDBC 2.0, see Don Denoncourt’s article “Test Driving JDBC 2.0

Security

JDBC

with jt400” in the April/May 1999 issue of AS/400 NetJava Expert (Web Edition) at www.midrangecomputing.com/anje/99/04
.

Collections

Java 2 incorporates significantly improved support for collections.

Collections are a vital part of object-oriented programming, as they enable you to address groups of objects without resorting to clumsy array programming. (As an aside, I spent a year trying to use an object-oriented database. The majority of the database code I used was involved in either accessing objects via collections or updating collections with new objects.) Collections are to object-oriented programming what logical files (or views) are to relational database programming. They are vitally important to Java being accepted in the enterprise.

The Java 2 Collections framework provides a clean, standard, interface-based set of classes and methods that are both simple and powerful. The framework also provides a set of sorting algorithms. Figure 1 provides a summary of the collection classes available in Java 2. According to the Java 2 docs, using the List, Set, and Map interfaces “reduces programming effort, increases performance, allows for interoperability among unrelated APIs, reduces effort to design and learn new APIs, and fosters software reuse.”

The good news with this improved collections support is that you no longer have to “roll your own” when it comes to Collections. The “legacy” collections (Vector and HashTable) have been retrofitted with the interfaces from the Collections framework. The bad news is that you’re actually ahead of Sun in this regard. There are several classes that return Collections, but most classes don’t use the Collections framework. For instance, JDBC does not.

CORBA Support

Also new in Java 2 is a 100% Pure Java Object Request Broker (ORB) that supports interoperability between the Common Object Request Broker Architecture (CORBA) and a Java Runtime Environment (JRE) through Java Interface Definition Language (IDL). CORBA is similar to Remote Method Invocation (RMI) but intended for distributed object applications. Unlike RMI, CORBA works between disparate computing languages and platforms. CORBA support in Java 2 may make developing with Enterprise JavaBeans (EJB) easier, as CORBA is a likely candidate for communication between Java environments and existing application services.

Java 2 also supports an implementation of the OMG/CORBA Object Transaction Service/Java Transaction Service (OTS/JTS) with an alternate Java API on top. This implementation allows a single transaction to comprise actions occurring on multiple virtual machines and multiple databases, including the application server, resource manager, and standalone transactional application. With this architecture, all those actions succeed or fail as a unit.

Earlier Java implementations required a print dialog (interactive), so you couldn’t automate print jobs. Printing in Java 2 now supports an optional print dialog. Located in the java.awt.print package, the main class for printing is PrinterJob, and you must implement the java.awt.print.Printable interface.

Look Forward, Look Back

Sun has pulled off an amazingly AS/400-like feat. Java 2 is fully backward-compatible with all previous versions of Java. No deprecated methods have actually been removed, nor are there any plans to remove them. Even the old 1.0 event model is still supported, so all your old source code should compile and run fine. Of course, your testing bears this out, right?

Printing

The Rule of Three

And so the Rule of Three holds true again. The Rule of Three states that any software product is not ready for “prime time” until the third release. The Java faithful have kept the torch burning through JDK 1.0.1 and JDK 1.1.x, and their faith has been rewarded with Java 2. Go forth and convert the masses!

Reference

“Test Driving JDBC 2.0 with jt400,” Don Denoncourt, AS/400 NetJava Expert (Web Edition), April/May 1999, www.midrangecomputing.com/anje/99/04

Related Materials

• ”At Long Last...JDK 1.2,” Alexander Day Chaffee, Gamelan’s Java Journal Tech Focus, December 2, 1998, www.gamelan.com/journal/techfocus/ 120298_1jkd12rev.html
• ”JDK 1.2: Features and Critiques,” Alexander Day Chaffee, Gamelan’s Java Journal Tech Focus, December 10, 1998, www.gamelan. com/journal/techfocus/ 120998_2jdk12rev.html
• ”Prepare Yourself for What’s New and Different in the Forthcoming JDK 1.2 Release,” John Zukowski, JavaWorld (Web edition), November 1998, www.javaworld.com/ javaworld/jw-11-1998/jw-11-jdk12_p.html

HashSet Holds an unordered set of objects with no duplication ArraySet Similar to HashSet but intended for smaller sets because it has faster creation and iteration than HashSet
ArrayList A dynamically sizable class similar to Java 1.1’s Vector class but unsynchronized
LinkedList A doubly linked list that may provide better performance if insertion and deletion occur frequently
Vector A dynamically sizable, synchronized array. The Vector class has been available since Java 1.0. Sun expects you to use one of the other Collection classes but still supports Vector for backward compatibility.

ArrayMap Intended for small HashTables because it has faster creation and iteration than HashMap
HashMap An unsynchronized HashTable
TreeMap A balanced binary tree implementation of the Map interface.

Unlike HashTable, it imposes ordering on its elements. HashTable Implements a HashTable that maps keys to values. Same as

JDK 1.1. The HashTable class has been available since Java 1.0. Sun expects you to use one of the other collection classes but still supports HashTable for backward compatibility.

Figure 1: The concrete implementations of Java 2’s collection classes give you perhaps too many options for holding groups of objects.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: