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.
DiffKit – Diff for Tables
DiffKit is an application, and a framework, for comparing two tables of data, field-by-field. The tables can come from any of a number of sources, such as an RDBMS or CSV file, and DiffKit is able to mix different kinds of sources in the same diff operation. DiffKit is like the Unix diff utility, but for tables instead of lines of text.
DiffKit is able to report the diffs at both the row and field level, and allows the user to configure the comparison (what to compare, how to compare it, what to ignore). DiffKit is highly customizable with respect to the sources of tabular data, the details of the comparison, and the characteristics of the output (diff report). DiffKit is free, open source software licensed under the Apache License 2.0.
Information excerpted from DiffKit’s website.
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.
If you see these or similar results, your Java environment works. Congratulations. You can check out the tests by cding into the tcr.run.184.108.40.206.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.”
Fatal error: Call to undefined function aa_author_bios() in /opt/apache/dms/b2b/linux-mag.com/site/www/htdocs/wp-content/themes/linuxmag/single.php on line 62