I love coffee, I love tea. I love the Java Jive and it loves me.* If Java is giving you jive, put your fears aside. You'll soon love it sweet and hot. Or maybe not.
How many times have you run into problems with Java? Chances are very good that most of you have. If you perform a Google search using the words “Linux” and “Java,” you’ll have an all-day scavenger hunt on your hands. Searching for answers to installing Java, making it work and surviving the aftermath could use up whatever energy you’ve gleaned from actual cups of java. If you install the correct package, you need never fret again. You’ll learn to love Java again. You might even sing about it.
There are so many options for installing Java on your system. There’s openjdk, Sun’s (Oracle’s) Official Java, and the various “renegade” versions such as kaffe or gcj. This tutorial focuses on the Ubuntu-packaged version of Sun’s Java 6 JDK.
Java installs simply on Ubuntu (8.04), using the following command.
$ sudo apt-get install sun-java6-jdk
Part of the tutorial requires Ant, which installs with the command shown below.
$ sudo apt-get install ant
Once installed, you should set your JAVA_HOME and CLASSPATH variables in your home directory’s .bash_profile file.
Logout and relogin to your system to have your Java environment variables set automatically.
Tasting Fresh Java
Once you’ve installed Java, and optionally Ant, it’s time to test the basic functionality to see if everything works as expected.
$ java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)
It’s always a good idea to test your Java compiler too.
$ javac -version
If those two respond appropriately, you might have conquered the Javasaur. The next section will provide feedback on the degree of your success.
The true test of your new Java environment is the ability to run real Java apps. The application for this test is DiffKit. Download and unzip DiffKit into your home directory.
As recommended on DiffKit’s website, you must first verify your environment to make sure that the standalone application works for your operating system and Java environment. Change directory (cd) into the diffkit directory and issue the following command. Expected responses shown.
$ java -jar diffkit-app.jar -test
TestCaseRunnerRun (flavor=H2) -- ./tcr.run.220.127.116.11.19.50
If you see these or similar results, your Java environment works. Congratulations. You can check out the tests by cding into the tcr.run.18.104.22.168.19.50 (Your directory name will differ) directory.
Since this isn’t a tutorial on DiffKit, you can discover its many uses beyond this tutorial. The Java implementation that you installed here has nothing to do with Java browser plugins. Those are separate installations. This is a pure Java environment for dealing with applications programmed in the Java language.
As you can see, Java doesn’t have to be a “black box” nor does it have to be difficult to install or use. And, you no longer have to fear Java applications on your Linux systems.
Java isn’t the friendliest environment with which to work. In fact, if Java were to hit the market today, it probably wouldn’t take hold like it has over the past 15 years. There are too many other capable languages that surpass Java in speed, simplicity, cross-platform ability and all with fewer pains of “getting everything right.” Java is too finicky and tends to be a memory hog. It’s unclear why any application developer or company of developers would continue down the Java path, when clearly there are better alternatives. To name a few: .NET/Mono, PHP, Python, Ruby. Apparently, even the Eclipse folks agree, since their website is PHP-based and not Java.
Feel free to carry on this discussion. You can call it Java Jive (Coffee Talk?). Talk amongst yourselves, here’s a topic: If Java were to be presented as a new language today, in 2010, how would it fare? Discuss.
Lyrics borrowed from The Ink Spot’s, “Java Jive.”
Kenneth Hess is a Linux evangelist and freelance technical writer on a variety of open source topics including Linux, SQL, databases, and web services. Ken can be reached via his website at http://www.kenhess.com
. Practical Virtualization Solutions by Kenneth Hess and Amy Newman is available now.