My Humble Java

rent a car bulgaria Buy this book at Amazon.com!I am satisfied with my grasp of Java. Grown men walking around in a cheesy t-shirt with a 1980s-style iron-on transfer of James Gosling stretched across their chubby bellies will quickly scoff at my low expectations of just how much Java can do. This is what I want Java to do:

  • Load Excel spreadsheets from the command line and ‘shred’ them into XML files written to disk according to a declared specification (in another XML file).
  • Load XML and XSLT files from the command line and generate more XML files singly or in batches.What you really see here is that I want Java to process XML and Office documents (in a Linux environment). You do not see any desires to run my code in some kind of massive, memory-leaking application server (from IBM). You do not see any desire to use famous design patterns to connect to a database with a half-dozen configuration files. No desire for writing a GUI destined for the Web using graphical drag-and-drop metaphors that “protect” me from JavaScript and XHTML.

My extensive investments in .NET technologies and a PHP framework leave me with ‘humble’ Java-related goals. Back in 2006, I expressed amazement with writing for the command line in .NET—well, here I am again with Java. I know Java programmers will scoff again at this but I actually condescend to the Java language through C#. I see Java as small and ‘cute’—while most “real” Java programmers work in teams of three or more tending to massive, enterprise-wide “solutions” with girders of tiers creaking and groaning.

The table below contains online resources that led me to this tiny morsel of satisfaction:

“[Java interactive command-line input](http://www.devdaily.com/java/edu/pj/pj010005/pj010005.shtml)” At the time of writing, I have not yet used the technique mentioned here: “While Java is generally used to create applets, servlets, and general-purpose applications, you may occasionally need to create applications that interactively communicate with a user at a command-line…”
“[Shell game: Read user input directly from the command line in Java](http://www.javaworld.com/javaworld/javaqa/1999-07/02-qa-shell.html)” Another classic from 1999.
“[The Java XPath API](http://www.ibm.com/developerworks/library/x-javaxpathapi.html)” This went a long way toward helping me write a generic utility class that returns a `NodeList` with XPath queries. [My .NET investments in XML](http://songhaysystem.com/document/number/53) served as guidance—*condescending* guidance.

It was here that I learned that some Java libraries require try-catch blocks (instead of less verbose if-then ‘gates’): “Notice also that these methods can throw several checked exceptions that I must declare in a throws clause…”

“[How to load a jar file at runtime](http://stackoverflow.com/questions/194698/how-to-load-a-jar-file-at-runtime)” [JAR files](http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html) are like DLLs. I can already easily load DLLs using my poor-man’s version of [Windows Workflow Foundation](http://msdn.microsoft.com/en-us/netframework/aa663328.aspx). So naturally (and condescendingly) I looked for the way to do the equivalent in Java.
“[Dynamic loading of class and jar file](http://twit88.com/blog/2007/10/04/java-dynamic-loading-of-class-and-jar-file/)” “To load a class dynamically is straightforward. Just make sure the `classpath` is defined when your program starts up.” The challenge of understanding the Java ‘class path’ was not so small and cute—more on this below.
“[Jar Class Loader](http://jcloader.sourceforge.net/)” The obligatory Source Forge project that is supposed to my timesaver. The Apache Foundation surely has to have something here.
“[URLClassLoader (Java 2 Platform SE v1.4.2)](http://java.sun.com/j2se/1.4.2/docs/api/java/net/URLClassLoader.html)” In case Source Forge and my Apache friends fail me, I might have to writing a little class loader myself. I’m pretty sure `URLClassLoader` will be involved.
“[StringUtils](http://commons.apache.org/lang/api/org/apache/commons/lang/StringUtils.html)” The Apache Foundation is dead serious about Java: “The [Commons](http://commons.apache.org/lang/api/org/apache/commons/lang/StringUtils.html) is an Apache project focused on all aspects of reusable Java components.”
“[Packaging Programs in JAR Files](http://java.sun.com/docs/books/tutorial/deployment/jar/index.html)” Eventually I had to calm down and figure how to run *one* JAR file—instead of working on loading multiple files. In “[Adding Classes to the JAR File’s Classpath](http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html),” my assumption was that I would get some idea why `–classpath` was being ignored and the entry in the manifest was not…
“[Java Tip 105: Mastering the classpath with JWhich—JavaWorld](http://www.javaworld.com/javaworld/javatips/jw-javatip105.html)” “Whether they would admit it or not, beginner and veteran Java developers alike have at some point (usually at the worst possible moment!) been tricked by the onerous classpath. As the number of dependent third-party and user-defined classes increases for an application, and the classpath becomes a dumping ground for every conceivable directory and archive file, it’s not always obvious which class the class loader will load first.”
“[Apache POI—Java API To Access Microsoft Format Files](http://poi.apache.org/)” Last, but not least: “The POI project consists of APIs for manipulating various file formats based upon Microsoft’s OLE 2 Compound Document format using pure Java. In short, you can read and write MS Excel files using Java. Soon, you’ll be able to read and write Word, PowerPoint and Visio files using Java. POI is your Java Excel solution as well as your Java Word solution. However, we have a complete API for porting other OLE 2 Compound Document formats, and welcome others to participate.”

This project is actually mentioned in Java Posse #215.

Comments

Java Excel, 2009-01-08 03:11:06

I have a prerequisite knowledge in C++ back in the days, which then sparked my interest in Java. Learning Java is quite overwhelming for me.

rasx()