Java
By Simon Bisson
The Java platform and language turned the developer’s world upside down 12 years ago. Simon Bisson explains why.
HardCopy Issue: 39 | Found In: Development | Published: 01/02/2008 | Last Revision: 06/07/2010
It’s no exaggeration to say that Java revolutionised application development. Building on the work done in high level languages like C++ and Pascal, and merging in the byte-code concepts used by intermediate code interpreters in data-driven 4GLs, Java brought ‘write once, run anywhere’ to the desktop of every developer. That philosophy was Java’s greatest strength. It was also its biggest weakness, as it unleashed user interface and development challenges that still exist - and which drive the two different development tool camps.
Java began life as a tool for developing set-top box applications, but Sun soon saw its promise as a general purpose language and released it to the world at large in 1995. Over the next 12 years Java has evolved, adding mobile and enterprise versions to the original desktop language. Recently open sourced, Java is now one of Sun’s key products – the company even changed its stock ticker to JAVA.
Tools for Java
They call it ‘eating your own dog food’ but the fact that many of the leading Java development tools are written in Java is a testament to the strength of the Java platform.
One of the more popular Java development environments is the Eclipse Foundation’s eponymous Eclipse. Eclipse began life as an IBM internal project but became an open source project in 2001. There’s a lot to Eclipse as it offers a framework for developing complex IDEs with debugging tools. Its licensing terms mean that it has become the basis for many commercial Java development tools, including Compuware’s OptimalJ (see www.greymatter.com/P149285).
CodeGear has used Eclipse as the basis for JBuilder 2007. JBuilder offers more features than its open source competitor, making it an attractive option (see www.greymatter.com/jbuilder). Intended to be used by teams of developers, JBuilder integrates with CodeGear’s team-based application lifecycle management tools. Enterprise developers will find its EJB workbench useful, along with its code optimisation tools and Web service visualisation features.
JetBrains’ IntelliJ IDEA offers built-in refactoring tools to help developers manage code complexity. There’s also support for common Java frameworks, including Spring, along with the ability to use JRuby and other Java-based dynamic languages. IntelliJ is also able to work with most popular source control systems, and can be used with Eclipse or its own IDE (see www.greymatter.com/intellij).
James Gosling’s original Java language was relatively simple and it’s retained its reputation as easy to learn while adding significant functionality. The release of the Enterprise Edition (JEE) made it easy to build and run complex n-tier Web applications, and an entire product class of application servers has appeared to host and manage these applications. Companies like BEA and IBM have developed their own application servers along with Sun’s own offerings.
There’s a lot of choice for enterprise Java developers, with a mix of commercial and open source tools. Java also includes tools for inline Web page applications in the shape of Java Server Pages. The Apache Group’s Tomcat quickly became the official JSP reference implementation. While Flash has replaced Java applets as the way to deliver applications on the Web, the recently released JavaFX platform offers developers a way of using Java to deliver what Adobe calls RIAs (Rich Internet Applications).
There are a range of different Java virtual machines for different platforms and you should find one fit for your purpose. Sun’s own JVM (Java Virtual Machine) is the most common while IBM and BEA have their own implementations. One of the more interesting recent developments has been BEA’s announcement of an OS-less JVM that can be hosted directly in a virtual machine, significantly reducing operational overheads and allowing virtual application servers access to more system resources.
The Java Community Process is the nearest thing to a standards process and it has led to the release of a wide selection of additional features and libraries. The members of the JCP have given Java the tools for working with portals and for delivering WS-* Web services.
Java Enterprise Edition
JEE is one of the most important Java variants. Designed to deliver large scale enterprise applications, its focus on a multi-tier scalable architecture with application components hosted on application servers makes it a popular approach for Web application development.
Managed by the Java Community Process, the JEE specification bundles several key APIs including JDBC, RMI and JMS. Other technologies considered part of JEE are Enterprise JavaBeans (EJB) and Java-based portlets. EJB is a way of hosting and managing distributed objects with tools for handling remote procedure calls and persistence (including object relational mapping to databases). Transactions and scalability are managed by application servers.
This approach means there’s no need to write housekeeping code so developers can focus on writing code that handles the application business logic. Everything else is handled by the application server and the JavaBeans container.
JEE also gives enterprise Java applications Web services support, while servlets are used to handle Web server interactions, making it easier to deploy large scale Web applications. Loosely coupled components can use JMS, the Java Message Service, to pass information and there are specific JEE connectors for many existing line-of-business systems. The current version JEE 5 was released in 2006. JEE 6 is currently under development with an anticipated release in 2008.
There is more to Java than the core language. A large selection of libraries extend and build upon the core platform giving you access to additional features that can be used to expand your applications. Web services are becoming increasingly important for distributed application development and Java is able to use a mix of XML and communications libraries to build interoperable applications.
Java’s communications libraries are a key strength of the language and include the Java Database Connectivity API (JDBC) which simplifies access to a mix of SQL and proprietary databases. Java also offers tools for RMI (Remote Method Invocation) and supports CORBA, allowing you to work with legacy enterprise applications.
One of the controversies that has faced Java has been how to deliver user interfaces across a wide range of platforms. One option is Sun’s own Swing while IBM’s SWT remains popular. Both take an agnostic approach to OS-specific UI widgets and can be used to deliver applications that meet native OS guidelines, or to offer UIs that have their own look and feel. Choosing a development environment can limit your choice of UI as not all are supported by every Java development platform.
Java developers have a selection of application frameworks they can choose from to help speed up application development. A mix of libraries and best practices, frameworks like Spring have become very popular. Spring offers developers an alternative to the complexities of JEE’s JavaBeans and has proven particularly useful in conjunction with agile development methodologies.
Microsoft’s .NET has been compared to Java and it’s true there are similarities, though these result more from similar design philosophies than anything else. For a start .NET is tied to the Windows platform, unlike the more open Java, and while Microsoft has implemented a Java-like language for .NET there are significant differences between J++ and Java. Now that Sun has open sourced Java it’s likely that the two frameworks will diverge even further.
Mobile Java (JME) has proved to be particularly popular. However there are significant differences between the various JVM implementations which has led to difficulties in true cross platform development, with applications that work on one phone failing on another. Google’s recently announced Android mobile platform introduces a whole new mobile Java implementation with its own virtual machine and a closer relationship to the desktop version.
How to shoot yourself in the foot in Java:
// The gun fires just fine but your foot can’t figure out what the bullets are and so ignores them.