Now let's cast an eye at the Java Client Side, the world of the Java user interface options.
Web Apps:
Web pages can be generated with Java using Java Server Pages (JSP) but often it is better to use a web application framework, as any non-trivial application using JSP can get very messy otherwise.
Sun's official Java web app framework is Java Server Faces (JSF). The idea is to treat chunks of web pages as components that can subsequently be reused. The Java crowd have not embraced JSF, however. Perhaps this is because JSF requires a learning curve that doesn't pay off as richly as it should. Though I have not used JSF much myself, so cannot comment authoritatively, there are grumblings that 90% of web coding is easier using JSF but the last 10% that JSF does not handle well can cause productivity slow downs that can corrode the benefit of using a framework.
The most widely used web app framework is Struts. Struts 1, in conjunction with Struts Tiles and Validator is a bit of a learning curve. Struts is powerful however. Operating at a lower level of abstraction than JSF Struts can more readily solve any reasonable web application programming problem: you are in total control.
Struts 2 is based on a merger of Struts 1 and "WebWork", with radical changes over the ageing Struts 1 framework. I can't comment on the new Struts 2 framework from personal experience yet, but it boasts very promising-sounding features and improvements. It's also simpler to use, according to the official blurb. If true - hurrah, about bloody time!
Tapestry is a niche framework but seems well-regarded. Another niche framework I haven't tried is Spring MVC.
To run these web apps you will need Tomcat, from Apache. (For highly advanced applications, any enterprise application server, such as JBoss or WebLogic, will run Java web apps. Enterprise application servers are mentioned later).
If your job is to create a powerful web application then have a gander at the amazing JBoss Portal, which is free and open source. There are proprietary licensed alternatives such as BEA WebLogic Portal, which is popular for most mega-project portals. Out of the box these give you "portlets", user management, layout management, theme management, resource management, security, all using an underlying database of your choice. Believe me, you have not got time to program these things yourself!
Web based applications are examples of "thin clients", you do not have to install client code on your machine other than, say, Firefox, to run a web app. The irony is that web app thin clients are fatter in terms of code you have to write than "fat client" applications, feature for feature. Fat clients are clients that you must install before you can use the application. Fat clients are similar to standalone applications except they talk to a server, and both can be implemented with the help of Swing.
Graphical User Interface frameworks
Swing is Java's default graphical user interface (GUI) framework. Swing is an aspect of the JVM, so a Swing app is guaranteed to work on any machine with a full working JVM and graphics capability. Swing could be better designed, but compared to writing web apps, Swing is a pleasure to work with, as it is easier to code and almost infinitely more powerful. Also with Swing you are not burdened with deploying code to an application or web container and then reaching for the web browser just to see the results of your coding. With Swing you just run your app with instant gratification.
Take event handling: to create application-like behaviour, such as responding to mouse clicks on things, web apps have to deal with the horrors of ECMAScript (aka JavaScript) coupled with the browser Document Object Model (DOM). Note that DOM was designed with documents, not applications, in mind. So the problem of turning a thin client document centric technology (web page in a browser) into an application (such as a well featured email client) has culminated in the ghastly abomination that is "AJAX".
AJAX is an almost inconceivably ugly pig load of hacks cobbling together the constraints of "DHTML" (HTTP, HTML, DOM, CSS, ECMAScript), XML, web browsers and web servers (supported by server-side coding) in the effort to turn a document into an application. If that were not grim enough, the misery is compounded by Microsoft's wretched IE browser, all versions of which intentionally break or lack support for W3C standards. This standards-breaking ruse is actually one of Microsoft's more childish tactics in the browser wars, which is making web developers' lives everywhere a living hell, costs organisations a fortune in increased development costs, and is holding back the web). So AJAX (along with most web development tools) is further bedevilled by ugly hacks and compromises to get web apps to work properly in IE, given that browser's bastardised proprietary corruption of web standards. Please encourage your friends to stay away from IE and use Firefox or Opera instead.
The extraordinary irony of this whole fiasco is that MS inadvertently invented one of the components of AJAX (XMLHTTP) that made AJAX, and hence interactive web apps, possible in the first place. This is about the only (useful) technology that MS invented, almost by accident (it took Google to actually take advantage of the technology and trigger the Web II revolution) and it is undermining Microsoft's desktop monopoly.
A Java Swing application works without modification on nearly all modern desktops and laptops without the hell of writing a web app. Of course, web apps do have the killer advantages of being spontaneous, you do not need to install them, and of automatically being the latest version. For a user the latter point can be a disadvantage - often a web app will, without warning, remove a killer feature, and you can never get it back! At least with a standalone app, you will always have that app, stable and free from external interference! (Unless the software is open to interference from Microsoft and can be remotely "de-activated" - Windows XP and Vista are two such villains that spring to mind). Demand to regain control over your own computer? Regain your dignity, use Linux, which also happens to be a very nice OS for Java development.
Java Swing development can be greatly improved by using "Explicit-tablelayout", an open source "layout manager" that is adept at arranging components. The default Swing table managers suck so explicit- tablelayout is an essential download. Another open source Swing-enhancing library is JGoodies: JGoodies "Looks", for example. The upside of Swing is that it is so flexible (which makes it a little awkward to program at first) that such libraries can easily improve working with it.
An alternative framework to Swing is SWT. The Eclipse IDE uses SWT, for example. Unlike Swing, SWT uses the graphical widgets of the native operating system, which can improve look and feel. However SWT breaks the Java ideal of portability across all platforms. SWT apps might not work on some less common platforms.
If Java currently has a weakness on the desktop it is Multimedia capability, especially video. Suns Java Media Framework (JMF) is badly designed, and has been rightly abandoned. On Linux, to display video on Swing I have had to resort to using JVLC. which is an open source wrapper of VLC, a Linux video playing application. On the bright side, VLC is a superb Linux application. However integrating JVLC into a non-trivial Swing application can be a little tricky. JVLC is also fairly limited: writing a video editing application in Java is not doable in a sane time frame. Hello, Sun Microsystems, we know you like to concentrate on the server side of things, but please make multimedia support in Java a priority, as the lack of good multimedia support is a show stopper for many developers.
Build Tools
Java applications can be automatically compiled and run, in Eclipse for example. But often a large project has requirements that require that a "build" must be configured. For many languages a build tool called "make" is used for this, but "make" is not often used for compiling and packaging Java projects. An XML based tool called "Ant" is commonly used. Ant takes a little getting used to. Ant works more like a relational language such as Prolog than Java.
An alternative to Ant that I love is Maven 2. Maven 2 (I'll call it just Maven from now on) is a build tool, and more. I prefer Maven over Ant for various reasons, not least because it dictates how your project is structured. Yes, this is a constraint, but constraints (or should I say standards?) can work brilliantly as they can save you much work. Maven can manage multiple projects and dependencies between them and third party libraries with great ease. Maven provides much more out of the box than Ant, with far less effort. Large projects have hundreds of lines of Ant code. Maven is free of all that bloat. I'll not go into the manifold capabilities of Maven here, but will pause to mention that Maven can generate Eclipse project files, so that you can import a Maven project (or projects) into Eclipse, and you are ready to go.
Source Control
Subversion is recommended, it's a very nice tool for controlling your source code and collaborating. Perhaps even more powerful is Git, originally written by Linus Torvalds himself, and notable for being used for Linux Kernel development. If you are dealing with a megabudget colossal commercial project, then Rational ClearCase has certain advanced features, but ClearCase is proprietary and usually requires a full time integrator and you have licence fees.
More Java to come...
The next page deals with Java software for Business, which usually runs on Servers. There are some server-side technologies that may be handy on the desktop too, such as "Spring", so it's worth a glance even for desktop developers.