Mike McCallister

Subscribe to Mike McCallister: eMailAlertsEmail Alerts
Get Mike McCallister: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

Related Topics: Java EE Journal, Apache Web Server Journal

J2EE Journal: Article

Tools of the Trade

Tools of the Trade

Sure, there's a JVM for Linux and applets will run in any Linux browser, but can you actually code from a Linux box?

When the GNU/Linux boom hit in the late '90s, all the hype was directed at the server. How Linux would save enterprises great gobs of cash in storage. How stable it was for next-to-no cost. How Apache stoked the furnace for the underfunded dot-coms slated to rule the universe.

In the face of all that hype, some may have thought that Linux was really just an OS for sys admins. What those people forgot is that Linus Torvalds invented the OS just so he could code at home.

While the jury is still out on whether Linux will ever conquer Aunt Sadie's desktop, it has always been a coder's paradise. That goes for Java coders, too. If you're a Java old timer, but a Linux newbie, follow me on this basic tour of how to write Java on Linux.

Five Easy Steps to Programming on Linux

  1. Install your favorite distribution.
  2. See what tools are already installed.
  3. Choose a JDK: Sun, IBM, Blackdown.
  4. Choose your environment.
  5. Start coding!
Getting Started
If you've been fearing Linux because of its legendary difficulty to install, stop worrying now. The "difficult Linux install" is increasingly a legend. These days installing any of the major Linux distributions (Red Hat, Mandrake, SuSE) is no harder than installing Windows. Basic hardware support is excellent and the installers all autodetect everything and install the proper drivers. (If you need more information on how to get a Linux distribution, see the sidebar "Getting Linux.")

The best part is once you have a distribution installed, you're basically ready to start coding Java. Distributions generally come chock full of development tools. Odds are at least one JDK is installed by default, along with the KDE and/or GNOME desktop environments, and a half-dozen text editors. My SuSE 8.0 Professional installation included the IBM JDK and has the two others available on CD or DVD.

Two advantages here: you can be confident that the JDK and the other applications included with the distribution have been tested and will work well on your system. The software is so easy to keep updated. Each distribution has a one-stop-shopping method of updating any app included in the distro. They have different names, but all you have to do is get online, run the update app, and watch it take care of the operation - no muss, no fuss, and (usually) no reboot required.

Pick Your JDK
As with many things Linux, programmers who want to write Java have an abundance of choices to make. After picking a distribution, next is which JDK to use.

You can get recent Linux ports of the J2SE and J2EE JDKs directly from the Sun Java site (http://java.sun.com/downloads). IBM also has a Linux JDK available for versions 1.3.1 and 1.4.0. IBM's version includes an enhanced just-in-time compiler, a mixed-mode interpreter, and a JVM. Free registration is required at both sites (if you haven't done that already).

The first official port of the Java software development kit was created by the Blackdown Organization (www.blackdown.org). You can download any version of the Blackdown JDK from their site. Blackdown is also the home for nearly all things related to Java on Linux.

The good news for Linux newbies is that both Sun and IBM give you the option to download their SDKs as an RPM file. The Red Hat Package Management system is a standard method of installing applications under Linux, and is supported by most of the popular Linux distributions (with the major exception of Debian). Running an RPM file will check your system to make sure all dependencies are present and install files into the appropriate directories.

Pick an IDE
The Linux Java developer has access to virtually everything the Windows or Solaris Java developer has. All Linux JDKs and JREs contain all the standard tools and technologies for their version. All the major Linux databases (MySQL, Postgre SQL, Oracle, etc.) have JDBC drivers for database connectivity. IBM offers a JavaComm implementation, and implementations of other noncore technologies are available for Linux. So with a command line and text editor, you can write Java from scratch. But how easy is that?

Fortunately, there are Linux tools to lighten the load. There are quite a few tools listed on the Blackdown Products page. I'll highlight a few of the most advanced: the Sun ONE Studio, Borland's JBuilder IDE, CodeGuide, the Emacs Java extensions (JDE), and JEdit.

Download any or all of these to see which fits your style best. The three commercial IDEs have 30-day trials; JEdit is free software; and JDE comes with the Emacs editor. Generally speaking, you probably want to use JDE only if you're already using Emacs.

Sun ONE Studio (Forte)
Sun's own offering is based on Forte's NetBeans and comes in three flavors: a free Community Edition, an Enterprise Edition for Java, and a Mobile Edition.

  • Community Edition: This surprisingly robust free option lets you build applets, JavaServer Pages, and servlets; supports the Ant build system; and includes the Java-based PointBase Server database and a Tomcat Web server. You get JDBC connectivity to any other database format. It also generates Javadoc, HTML, and XML documents.
  • Enterprise Edition for Java: While the Community Edition has generic support for J2EE, the Enterprise Edition (at $1,995) adds an RMI compiler, CORBA and application support, and the ability to create Enterprise JavaBeans. Enterprise also lets you create SOAP-based Web services. Additional stuff is available on Solaris, but Linux users should find this more than adequate.
  • Mobile Edition: This slightly stripped- down version takes out what you would expect (servlet and CORBA support, database connectivity) and adds the J2ME module.

    Borland JBuilder
    JBuilder gives you all the tools you'd expect in a modern IDE. Wizards to create projects, applets, apps, classes - even beans! - Swing and AWT GUI builders, debuggers, etc. As with Java, there are three flavors of JBuilder:

  • Personal Edition: Not just for embedded apps, JBuilder Personal Edition is a free download for creating all noncommercial Java apps, classes, and applets. This is a no-frills version (as you would expect), but is more than adequate for the beginning Java developer. You can write, debug, and optimize your projects. You also have access to the essential Java documentation within the Help system. The Personal Edition is currently at version 7, and builds to the 1.3.1 JDK by default. If you have another JDK on your system, you can replace the default JDK reference, but not add it.
  • Standard Edition: The Standard Edition adds the ability to write JavaBeans and use other J2SE tools. It uses Ant as a build system for your projects. Write to multiple JDKs, generate JavaDoc documentation, and get support for translation and CVS version control. Version 8 adds accessibility features for Section 508 compliance and red lines problem code. Download a 30-day trial from the Borland site.
  • Enterprise Edition: Borland throws in the kitchen sink in the enterprise version (the feature matrix document runs 17 pages!). Write EJBs (v1 and 2), EJB modules, and test clients, and make Enterprise Archives (EAR) and JMS projects. Use the Ant build system. The Enterprise Edition has extensive XML support, Rational ClearCase and Visual SourceSafe features, servlets for all major server types, a SQL tool suite, an embedded database, and JDataStore. You name it, it's here. Version 8 adds Web services support and a Struts application framework. The Enterprise Performance Bundle adds the Optimizeit Suite. Download a 30-day trial from the Borland site.

    CodeGuide from the German developer Omnicore is a low-cost ($299 for a single-developer license) cross-platform Java IDE for Standard and Enterprise Edition apps. It claims to analyze your source code on the fly, comes with Ant and Tomcat, and does instant compilation.

    Java Development Environment for Emacs (JDEE)
    The fabled GNU Emacs text editor (and its GUI clone Xemacs) has a storied reputation of being able to do just about anything within its confines. James Gosling even wrote his own version before the GNU project began. So, of course, Emacs does Java.

    The JDE major mode is written and managed by Paul Kinnucan. It's included with all recent versions of Emacs, but Xemacs users may have to download this package from the JDEE homepage (http://jdee.sunsite.dk). The site is worth checking out in any case.

    You must have a JDK installed for JDE to work, and a set of Lisp programs (the Enhanced Implementation of Emacs Interpreted Objects [EIEIO] object-oriented Lisp package, the semantic parser generator, and the speedbar file browser) accessible from the site.

    Opening a file with a .java extension in Emacs automatically puts you in JDE mode. You get a Java menu and syntax color coding; you can edit, compile, debug, and run files of all types; and you can use Ant or make it a build system. There's even a BeanShell command interpreter included with JDE.

    Much has been said in the pages of JDJ about the wonders of JEdit. This very cool Java-based text editor is, of course, multiplatform and also open source. JEdit is included with several distributions (though the one included with SuSE 8.0 is an earlier version), and can be downloaded either as an executable JAR or as a Linux-specific RPM.

    JEdit is very much like Emacs without the complex keyboard commands. It comes with syntax highlighting, a BeanShell interpreter, and a few Java-specific macros. Where the real power comes in is with the plug-ins contributed by the JEdit community. You can install new plug-ins or update your current ones right from the Plug-ins menu in the editor. The User Guide and help system explain both the macro language and the plug-in architecture so you can make your own.

    Yes, you can program Java in Linux. This article showed you how to get and install the three JDKs; introduced the Red Hat Package Manager; and described Sun ONE Studio, Borland JBuilder, Omnicore CodeGuide, JEdit, and the Java Development Environment for Emacs (JDEE).

    Further Reading
    If you are interested in coding Java under Linux, check out Java Programming on Linux by Nathan Meyers. Only slightly dated, the book describes everything you need to know, and attempts to be comprehensive in identifying tools. Its companion Web site, www.JavaLinux.net, is an important source for updated information and essential links for both Linux and Java beginners.


  • Blackdown Organization and Java-Linux archives: www.blackdown.org
  • Links to all Linux JDKs: www.javalinux.net/JavaLinux/SDK.html
  • Nathan Meyers' Java-Linux FAQ: www.jguru.com/faq/Linux
  • Blackdown's Java-Linux FAQ: www.blackdown.org/java-linux/docs/ support/faq-release/FAQ-java-linux.html
  • Java Development Environment for Emacs: http://jdee.sunsite.dk
  • JEdit: www.jedit.org
  • Borland JBuilder: www.borland.com/jbuilder/index.html
  • Sun ONE Studio: www.sun.com/software/sundev/jde/index.html
  • CodeGuide: www.omnicore.com
  • A comprehensive list of Java-related RPM packages: www.jpackage.org

    Mailing Lists/Support
    The Java-Linux mailing list is a place for news and troubleshooting problems. It's archived at the Blackdown site. Subscribe at [email protected] blackdown.org with subscribe in the subject.

    Run into trouble with JDEE? There's an active listserv of 600+ Emacs Java junkies ready to help. Send a blank message to [email protected] to check it out. A searchable archive of the list is also at the JDEE Web site.

    JEdit handles support through its community site, http://community.jedit.org. There are over 3,000 registered members on the site, and on a recent visit there were 300 guests to just 5 members, indicating an even larger community.


    Installing Your JDK
    On the off chance your distribution doesn't have the JDK you want, you may have to do the heavy lifting of installing it yourself. Here's how.

    Installing an RPM
    In MS Windows, installing any new application is usually just a matter of double-clicking setup.exe. The install file does the rest, with the occasional user prompt. The Red Hat Package Management system is a largely successful Linux way to do the same thing.

    To install the Sun or IBM JDK/JRE from its RPM file, type rpm IBMJava2-SDK-1.4-0.0.i386.rpm from a terminal prompt. If you happen to be working from a GUI desktop, open a file manager like Konqueror (in KDE) or Nautilus (in GNOME) and - surprise! - click! From Konqueror, KDE will load the KPackage RPM front end. Check your preferred options and click Install. After verifying that you have Root privileges, RPM checks for all dependencies, then installs the package where it should go (most times there aren't options here).

    Installing from a Tarball or Bin File
    The Blackdown JDK/JRE only comes in tarball format, though for v1.4 the tarball is wrapped in a self-extracting bin file. For those of you used to Windows, tarballs (i.e., files with a tar.gz extension) are Unix archives, just like ZIP files. To install the Blackdown JDK, follow these steps:
    1.   Open a terminal. Log in as Root or SuperUser (su).
    2.   Change to the directory where the JDK file (j2sdk-1.4.1-beta-linux-i586.bin) is. Ideally, you've downloaded the bin file to the install directory (Blackdown suggests installing to /usr/local). If you downloaded to another directory, copy the file over.
    3.   Make the bin file executable: +x j2sdk-1.4.1-beta-linux-i586.bin.
    4.   Run the bin file: ./ j2sdk-1.4.1-beta-linux-i586.bin.You'll be asked to agree to the license, then the file will extract, creating a new j2sdk141 directory with several new subdirectories.
    5.   To give the system a pointer to this SDK, add this path statement: export PATH=/usr/local/j2sdk1.4.1/bin:$PATH. This is especially important if you have other JDKs or JREs on your system.

    If you download a plain tarball from Sun or IBM, make sure the .tar.gz file is in the install directory, then type this command from the terminal:

    Tar -xzvf j2sdk-141-beta-linux-i586.tar.gz


    Getting Linux
    Want to get going on Linux, but haven't installed it on your box yet? You have choices. Different companies bundle the Linux kernel with different application packages, installation methods, and service/support options. These are called distributions. The practical differences between various Linux distributions are small (especially compared to the differences between the various Unixes), so virtually any Linux-specific app will run on any distribution, and all have a JVM to run Java apps.

    There are dozens of distributions to choose from, if you're so inclined, but the vast majority of Linux users pick one of the distributions listed in Table 1.

  • More Stories By Mike McCallister

    Mike McCallister is a freelance Linux writer based in Milwaukee and is constantly on the lookout for interesting documentation projects. Mike is the author of Computer Certification Handbook (2000, Arco Press).

    Comments (11)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.