HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 
Java & Linux, 10 Feet Tall And Bullet Proof, by Ben Okopnik

Linux from its inception was written by programmers for programmers. In the years since, the GUI interfaces and other user-friendly items have raised the warm and fuzzy quotient to make Linux accessible to the casual user. However, the core idea remains: provide maximum support and usability to the people who make the software happen. That commitment continues; after all, the people who make Linux grow, the ones responsible for its tremendous success, are almost all programmers - techies! - and as such, are interested in better tools first; the nifty toys to be built with those tools are "a trivial excercise left to the student."

7. Note on Java support. This software product contains support for programs written in Java. Java technology is not fault tolerant and is not designed, manufactured, or intended for use or resale as on-line control equipment in hazardous environments requiring fail-safe performance, such as in the operation of nuclear facilities, aircraft navigation or communication systems, air traffic control, direct life support machines, or weapons systems, in which the failure of Java technology could lead directly to death, personal injury, or severe physical or environmental damage.
-- [Excerpt from the Windows NT license agreement
(no copyright notice)]

FUD (Fear, Uncertainty, and Doubt) tactics are a negative decision factor. It tells you what to stay away from, not what to go toward. How's this for positive info: the Linux kernel has built-in Java support that lets you run your executables and applets right from the command line; it's Java-friendly from the start.

Given its nonhierarchical "bazaar" method of software development and the fact that it's a result of a cooperative effort, Linux has always been a haven for programmers and developers. Those of you used to MS Windows may find that the Linux tools are perhaps not quite as "slick"; however, you'll discover much greater flexibility and power as well as finer-grained control over the development environment. A number of benefits are inherent in the OS itself: I've become rather attached to the idea that computers are indeed reliable tools that don't crash and have uptimes measured in years instead of hours.

Welcome to the world of open source software.

More than 90% (my estimate) of Linux/GNU software is open source and noncommercial. Most of the rest is "nonfree" but doesn't require payment (e.g., Netscape Communicator, the JDK); only a small percentage is commercial (and may or may not be open source).

Given the recent tremendous growth of Linux in the marketplace, chances are that one day soon you'll have an opportunity to work with Penguin Java (Linux's logo is a cute little penguin named Tux). Of course, a myriad of questions spring to mind: How difficult will it be? What are the available tools? Is there any support? Is there an IDE?

If you like the idea of development unrestricted by proprietary licenses - free or open source software is the keystone of Linux/GNU - you'll also have the option of compiling your code without using Sun's Java Development Kit (though the JDK is also available). Linux is all about choice: you can use what's available (a very broad range), modify an existing program (and perhaps release the new version to the Linux community), or write your own (the number of compilers and interpreters that come with the average Linux distribution is nothing short of astonishing).

In addition to the software being Free, almost all of it is also free: if you wanted to (and had the patience or the bandwidth) you could connect to, say, ftp.debian.org or ftp.redhat.com, download the entire distribution, and install it. There's nothing to stop you; in fact, that's the very reason for that server's existence. Go ahead - cut CDs from what you download and give a copy to all your friends; you're more than welcome.

Shocking difference in attitude? No threats of doom, gloom, or plagues for copying? No "per seat" licenses? Nobody's even mentioning lawyers?

Full Disclosure
Before we go any further, several items are worth noting. I'm a Linux enthusiast and a computer professional with over 20 years of experience; a fair bit of that time was spent writing code. What I'm not is a professional Java developer or even a skilled Java programmer. The use of large-grained salt is strongly recommended when reading any of my Java-specific comments.

An FYI item for folks unfamiliar with UNIX in the Windows world, command line utilities are deprecated and mostly ignored; in Linux (and UNIX in general) they thrive and flourish. In fact, these tools have been polished to a high gloss by user feedback over the years until they're as close to perfection as possible - you'll be able to do things that are very difficult, if not impossible, in GUIs.

For example, a few days ago I had to work with a group of autogenerated HTML files, each of which had a number of links to other HTML files within that group. The problem was that the files themselves didn't have an .html extension - either in the original file names or in the links - which caused at least one browser to read the links as text files rather than HTML. A few seconds of thought and:

perl -pi -e s/'<a href="[0-9]*'/'$&.html'/g * for n in *.[^h]*;do mv $n $n.html;done
That's about 10,000 links in around 1,000 files- all fixed in a few seconds using two short command lines. If I had to do it with a GUI... frankly, I'd be lost.

(For the curious among us, in the first line I used Perl ["The Swiss Army Chainsaw"] to loop through every file in the directory and append an .html to the appropriate strings. The second line added the extension to the filenames that didn't already have it.)

One of the "problems" any new Linux user faces is that there are no $2x108 ad campaigns with heavenly choirs and dancing hamsters to tell you that this is The One True Software that will do everything you've dreamed of (including washing your dishes and getting you a date with Gillian Anderson). Linux/GNU software, by contrast, is typically produced by individuals or groups who aren't charging any money for it, and thus (oh, horror of horrors in this world of modern marketing!) don't have advertising budgets; even the best software tends to be "advertised" with no more than a two- or three-line description in the package list. Usually, it takes a bit of experimentation - installing the programs and working with them - to decide what you like, what works well for you, and what will enable you to be as effective as possible. It's a very different methodology from that of buying the software and either being stuck with it or having to fight the Battle of Refunds.

Table 1

Running Linux requires you to think of software in a different way. My contention is that to a large and rapidly growing number of people - of whom I'm one - it seems to be a better way.

The Various Flavors of Linux
The choice of a distribution seems to be a major and confusing topic for anyone interested in installing Linux. In very broad terms and with a strong dash of personal opinion, here's my 2.

The Linux kernel - the part of the OS that provides resource allocation, I/O services, and more - is the same in any distribution for a given architecture (except for the version and compilation options). What varies is the installation procedure, the package method, the number/type of included programs, and the filesystem layout. The most common choices these days are RedHat, Debian, SuSe, Mandrake, and Slackware, with a few companies trying to carve out niche markets (e.g., Caldera's "OpenLinux" claim to fame is complete Novell Netware interoperability). A large number of less well-known distributions are available. Table 1 provides a short list (my familiarity with these ranges from excellent to minimal).

The package method that each distribution uses - the format of the setup files used to install the software, its associated documentation, and more - is somewhat different but convertible. For example, a RedHat Package Manager file (an RPM) converts to a DEB package in a few moments via the "alien" utility and is then install-able on a Debian system or vice-versa. Given a standardized method of package installation within a distribution, software uninstallation is a clean and well-defined process without stray files ending up in odd corners.

A handy utility for Debian, by the way, is a program called apt-get (RedHat's equivalent is rpmfind). If you know the name of the package you want to install (say, the Java Development Kit), simply type:

apt-get install jdk1.1-dev
apt-get will query the previously specified archive servers, then download and install the latest version of the software you've requested, as well as any other software that's a prerequisite for it. By using other switches of apt-get, such as "update" and "dist-upgrade," you can check for newly released packages or even update your entire system at once.

Which distribution should you get? Like many other Zen questions this one has no Right Answer.

Myself when young did eagerly frequent Doctor and Saint, and heard great Argument About it and about: but evermore Came out by the same Door as in I went.
- The Rubaiyat of Omar Khayyam, XXVII, tr. by Edward Fitzgerald

If you're going to take the time to configure your system to your personal preferences - who among us doesn't? - and given the fact that almost any package can be converted, the differences begin to fade anyway.

The Iron Hand in the Velvet Glove
Most Linux distributions default to a GUI upon installation. This gives you a comfortable familiar interface. But what if you need to perform some complex file operation (as I did, above) or run some app that prints to the console? An application called xterm (X Terminal) is installed with the X Window system; newer, better versions such as rxvt and gnome-terminal also exist. All of these resemble a DOS window but provide infinitely greater functionality. Bash, the default shell (other command language interpreters are available), has a long list of quite respectable capabilities: subshell support, a powerful scripting language, editable command history, full multitasking, process control, and many others. That plain-looking prompt isn't all that plain anymore.

For those of you familiar with DOS's Norton Commander, a pleasant surprise: Linux has a program that took off on that theme and ran far and fast. Midnight Commander by Miguel de Icaza incorporates things like FTP, virtual file systems, graphical background process control, and many other features. mc is a file manager that runs in an xterm window (a GUI version called gmc is the default file manager under RedHat). File operations such as copying, moving, deleting, compressed file viewing, and package installation are handled by a single key press (Norton fans, these are the same keys you're used to!), and you can easily configure mc to perform complex operations based on the file type and the desired action (opening, viewing, or editing).

Setting Up the Workshop
These are the packages I installed for this project (a number of others are related to Java but these are a good start):

// jdk1.1_1.1.7v1a-2.deb Runtime part of the JDK (JRE)
jdk1.1-dev_1.1.7v1a-2.deb Java Development Kit
biss-awt_0.87-1.deb Java AWT
tya_1.1v3-3.deb JIT compiler (a JVM extension)
guavac_1.0-5.deb Open Source Java compiler
xwpe_1.4.2-2.1.deb "Turbo-C"-like programmer's editor
jde_2.1.1-4.deb Java IDE for the Emacs editor

The first two packages comprise Sun's JDK. The good folks at www.blackdown.org, the ones who are doing the JDK for Linux conversions, are up to version 1.30, and the latest news and downloads are available right from their site. Note that the JDK is released under the Sun Microsystems' license and thus is nonfree software. You won't be asked to pay for it, but anything you create by using those tools is encumbered by a number of legal restrictions (this is true no matter what OS you use; the license applies to the tools). Under Linux, at least, you have the option of avoiding that by using the Open Source compiler (e.g., guavac) and the JDK tools for, say, debugging.

Once we have a compiler and a debugger, we need some type of an IDE. The X Window Programming Environment (xwpe) is a Turbo-C-like editor/IDE (see Figure 1); for those who like those old-fashioned tools (okay, I'll admit it - call it nostalgia!), it's a well-written piece of software that will run either from the console (in text mode) or under the X Window system. The environment is easily configurable for most of the common languages including Java. Small, simple, and functional - if that's your preference, then xwpe is the way to go.

Figure 1
Figure  1:

On the other hand, if you like software that can do everything and then some, FSF GNU Emacs and its GUI cousin, XEmacs, are the unbeatable choice. With the addition of the Java Development Environment (JDE) package, above, Emacs becomes a full-blown and highly configurable Java IDE (see Figure 2).

Figure 2
Figure  2:

Some people prefer vi, another (reputedly) powerful and highly customizable editor. For myself, well, even the thought causes me to hunt for strong beverages and turn a slight shade of purple. The first time I tried vi it took me an uncomfortable number of minutes to figure out how to exit the thing without resorting to kill. Even after a close study of its manual page I avoid it when I can... but I'm willing to accept that there are people who love it.

When experimenting with the IDE/compiler combinations, I used my slowest machine - a 166MHz 16MB laptop - to get distinct measurements. I found that guavac was significantly faster than javac, while the choice of interface made little difference (less than one second in the worst case). As a baseline (i.e., when executed right from the command line), a simple "HelloWorld.java" took 19.33 seconds to compile with javac the first time versus 5.34 seconds for guavac. Once caching was in effect (subsequent runs), javac averaged 11.42 seconds, guavac 3.95 seconds. Compiling larger projects (I downloaded some code from the Web) provided comparable results.

A Supporting Cast of Thousands
One of the best things about Linux is the amount of information available on any topic of interest. The Linux community is a Net-enabled phenomenon in which the watchwords are cooperation and sharing.

The open source idea can be an excellent business model. There's a site (www.cosource.com) where you can browse for open source software contracts, see the amount that people are willing to pay for the creation of that software (the bounty is an aggregate of all the interested sponsors' contributions), and decide if the money offered is worth your time. It's a new method of creating customer/developer relationships and perhaps a chance for an unknown hotshot programmer to make his or her reputation. Say, could that famous person be you?

State of the Union
Today, Linux is a mature, stable, powerful OS that has penetrated deeply into the business and home desktop market. Companies as diverse as IBM, Oracle, Hewlett-Packard, Compaq, Corel, and many others have joined the flood of supporters of open source. Linux has controlled experiments in outer space, been built into watches and car audio equipment, runs the world's smallest Web server at Stanford and the largest clustering network in Australia, and has been nominated by IBM to run on their biggest machines. The plans for the future include exciting technologies that are being implemented even as you read this article. If you have a brilliant idea that may bring the world to your door, there's nothing to stop you from developing it and an entire community to help.

The high-speed rocket to the future has arrived and you're welcome aboard.

References

  1. "The Cathedral and the Bazaar" by Eric S. Raymond: www.tuxedo.org/~esr/writings/cathedral-bazaar
  2. "GNU General Public License": www.gnu.org/copyleft/gpl.html. Also Richard Stallman's "GNU Manifesto" gives a broader view of the original principles of the Free Software movement.

Resources

Author Bio
Ben Okopnik is a contributing editor to the Linux Gazette. He's been playing with computers since the late '70s and working in the field since the early '80s. He can be reached at: [email protected]
 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.