What are Some Essential Java Libraries?
rleclerc writes "I would like to ask those 'Javaniers' in the Slashdot community what they thought were essential non-standard libraries that every Java coder should have. Normally I roll my own when it comes to that type of thing and simply build on whats available in the foundation classes. However, recent work has pushed me toward looking at some scientific libraries and I thought I would find out what libraries others in the Java community would consider an essential weapon in their Java arsenal. A few that I am looking at are the Cern scientific libraries and the Apache Commons Collections libraries. To avoid extra libraries I have opted to use the Java logging rather than the Apache one. Anyone like to add anything to the list?"
In no particular order...
Commons Logging. Yeah, you said you wanted to avoid extra libraries, but the overhead of commons logging is so incredibly small, and the extra libraries you'll want to otherwise use are going to require it anyway. It's a measly 28KB last I checked, and well worth it.
HttpClient If you want to do any form of HTTP transfers, avoid HttpUrlConnection (built in to Java) at all costs. The HttpUrlConnection code is broken in many ways (too many to list), so you'll need another library. HttpClient does a good job of hiding the HTTP transfer behind the scenes, and has easy ways of letting you extend/change what you need.
JGoodies Looks Swing is getting better every day, but for that extra polish, you'll want to use the JGoodies Looks library. It does a great job of making Metal look just that much better, and also helps out the Windows L&F in some places.
Xerces I'm not sure if the bulk of this is included in the latter versions of Java, but Xerces is definitely a must-have for any XML parsing.
Other goodies...
For rendevous (multicast DNS) support, use jmDNS. It just works.
If you need i18n handling (normalization, etc..), IBM's icu4j does a great job.
The last several projects have included jakarta-regexp-1.3.jar. Yes, if you are lucky enough to be able to count on using JDK 1.4 you have another option. One jar and you are golden for regular expressions.
The other is import org.apache.xpath.XPathAPI; My god is it nice to be able to say
NodeList nl = XPathAPI.selectNodeList(doc, "config/adapter/config/property[@name='foo']");
than the normal horking about with SAX or DOM parsers.
+++ UGUCAUCGUAUUUCU
Xalan for XSLT and XPath processing. Here's a tip: Never, ever use SAX for XML parsing of application-specific data structures. SAX is a nice low-level interface for building upon, but unless you're programmatically emitting a document from scratch, it's painful to use -- you always end up writing a stack-based content handler to keep nesting state. XPath makes parsing a breeze.
JGroups (formerly JavaGroups) is a protocol stack for building reliable, fairly efficient network communications based on, among other things, multicast IP. The entire stack is user-defineable, so you can pick and choose the level of reliability and which features you want (TCP support, pinging, group membership management etc.).
Lucene is a text-indexing engine. It's actually pretty crap, and does not scale very far (we're talking a few seconds for result sets of only a few thousand documents), and the code is pure spaghetti (abstract base classes! Inheritance!), but if you need a little indexing engine or some decent text tokenization classes, and your performance requirements are modest, it works well enough.
SableCC is a good BNF-based parser generator that generates type-safe parse trees that can navigated at runtime. Unlike the more well-known JavaCC, it's easy to get started, not least because the BNF-like grammar is so simple.
Wrong Commons. It's called Jakarta Commons and is alive and, despite a certain tendency to include crappy, hastily-thought-out and sloppily-designed implementations, generally considered well.
Doug Lea's Concurrency Utilities - If you haven't yet made the plunge to Java 5.0, this is indispensable for anything thread related.
Trove4J - High performance collections that work with primitives. We do wire-speed packet capture and flow analysis with this stuff. 'nuf said.
"Let your heart soar as high as it will. Refuse to be average." - A. W. Tozer
I'm currently building a variety of petroleum engineering tools in Java. Here are the libraries I've found most useful:
JFreeChart - for all your plotting needs. Robust, quick, and fairly bug free. Not perfect, but hackable.
iText - a free Java PDF library. My preferred method for creating reports, especially since a lot of my output needs to be e-mailed or submitted to the government, not printed out.
JAMA - a Java Matrix package. The fact that this library has a working singular value decomposition has saved me bunches of time programming a boring and tricky algorithm. I guess it has other stuff, too.