What are Some Essential Java Libraries? 77
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?"
Libraries (Score:2)
Don't write off log4j.
Spring is very good indeed.
List (and reasons) (Score:5, Informative)
Commons Logging. [apache.org] 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 [apache.org] 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 [jgoodies.com] 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 [apache.org] 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 [sourceforge.net]. It just works.
If you need i18n handling (normalization, etc..), IBM's icu4j [ibm.com] does a great job.
Re:List (and reasons) (Score:1)
JoAnn
Re:Commons Logging is crap (Score:2)
Sure, it's not a logging system -- but it's a damned fine logging layer.
Re:Commons Logging is crap (Score:3, Interesting)
Re:Commons Logging is crap (Score:3, Informative)
Re:Commons Logging is crap (Score:2)
On Websphere, commons-logging plugs into Websphere's own logging facility. I do all my logging that way. If I ever need to deploy the application to another application server, I'll just need to configure log4j or JDK 1.4's logging.
Apart from that, it's a light-weight library, easy to use (very similar to log4j).
Re:List (and reasons) (Score:1, Insightful)
How many other classes in the Java standard library are the same way? I'm trying to formulate a position on whether Java would've been better off to not have so many classes by default and rely on some other process to build a big armory of classes (like Perl), or if they indeed took the right path by having so many classes by default (it means companies can build on a huge amount of code that comes di
Re:List (and reasons) (Score:3, Insightful)
The remaining object-oriented pr
Re:List (and reasons) (Score:2)
String[] tokens = wholeString.split("regex");
will do the same thing, a lot more efficiently.
number of tokens? tokens.length.
Plus, it's a single line to tokenize the string that way, rather than dealing with new StringTokenizer(), getnexttoken, etc.
Re:List (and reasons) (Score:1)
Re:List (and reasons) (Score:1)
jython (Score:1)
My top 5 (Score:4, Informative)
JDOM.org (Score:2)
Re:JDOM.org (Score:2, Interesting)
My last couple... (Score:4, Insightful)
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.
Re:My last couple... (Score:1)
-the hermit
A few I use a lot (Score:3, Informative)
The pre-1.5 concurrent threading classes [oswego.edu]
Command-line argument handler library [apache.org]
Log4J [apache.org] logging.
Before any project... (Score:3, Interesting)
First, make a plan of what your trying to do.. then go browse apache Commons.
There have been many times I got through a project, or part way into it.. and realized I could of saved a TON of time by using a tool from that resource.
If your doing anything with XML, it's worth taking a look at JDom.
Make sure your using Eclipse, and if your doing web based projects.. I highly recomend http://myeclipseide.com. I have been a subscribe for a while, and have really enjoyed the enhancements that their modules bring for web development.
Re:Before any project... (Score:2)
Bad mojo man...
From the site:
Unfortunately, the project never gained critical mass, so it was deemed best to close it (in August, 2004).
Looks like you'll have to find a new way to start projects. Bummer.
Re:Before any project... (Score:4, Informative)
Wrong Commons. It's called Jakarta Commons [apache.org] and is alive and, despite a certain tendency to include crappy, hastily-thought-out and sloppily-designed implementations, generally considered well.
Re:Before any project... (Score:2, Informative)
http://jakarta.apache.org/commons/index.html [apache.org]
Correction: Jakarta Commons, not Apache Commons. (Score:1, Redundant)
http://jakarta.apache.org/commons/index.html
Cheers
First Stop Apache Jakarta (Score:1)
The rest depends on the frameworks I am using and the project.
I used to roll my own, but now I tend to do a web search for what I want before resorting to building my own.
cglib and more (Score:4, Interesting)
Xalan [apache.org] 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 [jgroups.org] (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 [apache.org] 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 [sablecc.org] is a good BNF-based parser generator that generates type-safe parse trees that can navigated at runtime. Unlike the more well-known JavaCC [java.net], it's easy to get started, not least because the BNF-like grammar is so simple.
Re:cglib and more (Score:3, Informative)
Re:cglib and more (Score:2)
Nothing -- if you use them correctly. In the case of Lucene, there is no clear separation between interface and implementation, and the implementation itself frequently violates good design principles such as separation of concerns and encapsulation. (The author of Lucene also seems ignorant of the fact that Java has an interface keyword. Pure abstract base classes have their place in MI languages like C++, of course.)
Re:cglib and more (Score:2)
Because inheritance breaks encasulation. When given the choice between composition and inheritance, you should always choose composition. With a well encasulated library, you won't need to dig into the source. Chances are, with a lot of inheritance, you'll need the original library source even for the most basic use of that library.
Re:cglib and more (Score:2)
some resources to consider are (Score:2)
Usefull libraries (Score:3, Informative)
Text I/O and processing (Score:2)
Caveat: I haven't used Java since about 1.3, and I hear they've improved the text APIs significantly in 1.4 (or was it 1.5?).
Yajul (Score:3, Informative)
It has lots of obvious classes that you'd almost expect in the JDK like TeeOutputStream, ByteCountingOutputStream, Cache, and StringUtil.
My Favorites (Score:5, Informative)
Doug Lea's Concurrency Utilities [oswego.edu] - If you haven't yet made the plunge to Java 5.0, this is indispensable for anything thread related.
Trove4J [sourceforge.net] - High performance collections that work with primitives. We do wire-speed packet capture and flow analysis with this stuff. 'nuf said.
Re:My Favorites (Score:1)
What would be even cooler is an equivalent JSP taglib...
Does anyone know if such a component exists ?
Q.
Re:My Favorites (Score:1)
My most favourite (Score:4, Interesting)
I'm currently building a variety of petroleum engineering tools in Java. Here are the libraries I've found most useful:
JFreeChart [jfree.org] - for all your plotting needs. Robust, quick, and fairly bug free. Not perfect, but hackable.
iText [lowagie.com] - 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 [nist.gov] - 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.
Freemarker (Score:1)
A couple of template packages that are good:
Freemarker [freemarker.org]
Velocity [apache.org].
And if you need to perform pdf manipulation: Big Faceless Java PDF Library [faceless.org] It's not free but it's a really nice package
Re:Freemarker (Score:1)
I haven't used FreeMarker, but it claims to fix that kind of stuff. Next time...
Re:Freemarker (Score:1)
Re:Freemarker (Score:2)
Interesting, this is the first post I could find that mentions any framework libraries. Does everyone here just use straight JSP?
I would be interested in /.er's opinions on framework libraries such as struts [apache.org] and hibernate [hibernate.org].
org.apache.commons.beanutils (Score:1, Interesting)
I'll see that quote, and raise you another (Score:3, Insightful)
parent is not troll (Score:2)
POBS (Score:1)
Apache offers a lot of good tools, most of which are considered "standard". Jakarta Commons and Xerces in particular.
If you need to create custom parsers (i.e. embedded languages or custom file format), take a look at pobs.sourceforge.net
Other than those, I use no external libraries at the moment, mainly because I have no need for anything else.
It's only a layoutmanager but... (Score:1)
Depends on what you intend to do (Score:2)
Apache is your one stop shop (Score:3, Insightful)
Junit is indespensible and these days with the IDEs indistinguishable from the core java libraries themselves.
Don't write SQL, use hibernate.
For security, you cant go past the legion of the bouncy castle (I'm serious)
Use cruise control to set up a continuous build
And the *only* piece of closed source code we rely on is Clover coverage. It's simply fantastic. You'll love it if you adopt unit testing as your quality mechanism.
Re:ANT... (Score:2)
Anyhow... I'm going to be starting a job soon where Maven is the build tool instead of ANT. I've been using ANT for years. Does
Does anyone know of any good references... I wasn't able to
Re:ANT... (Score:2)
The Bile Blog [jroller.com] has plenty to say about it.
I think Maven may work if you don't mind drinking a bit of kool aid and structuring your project around your build tool, rather than the other way round.
Jamon (replacement for JSP) (Score:1)
Fastutil (Score:2, Interesting)
MG4J [unimi.it] from the same place is pretty interesting too.
xmlenc (XML output library) (Score:1)
It's simple, fast and the memory footprint is negligible. It does not have the overhead of DOM-based solutions.
jdbc, snmp, (Score:2, Informative)
JDBC - mysql or postgresql or oracle-classes.jar
we, an ISP, do lots of networky stuff with SNMP; Jonathan Sevy has a nice easy to use class library:
http://edge.mcs.drexel.edu/GICL/people/
crypto - Re:jdbc, snmp, (Score:2, Informative)
these guys know what they're doing, winning awards in a david-vs-goliath arena:
http://www.bouncycastle.org/
Prevayler and HttpUnit (Score:2)
The other things I use regularly are HttpUnit [sourceforge.net], a virtual web client and Prevayler [prevayler.org], a simple Java persistence framework.
OpenMap (Score:1)
XOM! (Score:3, Informative)
It's created by Elliotte Rusty Harold, who is one of the bigwigs in both the XML [cafeconleche.org] and Java [cafeaulait.org] arenas. XOM is at the intersection of those two sets.
Technically it's still in "beta", but the API hasn't changed at all since the Alpha releases, and all the bugs fixed in the beta stages have been for performance boosts or to fix bugs dealing with the very fringes of XML.
Probably the best part of the library isn't the code itself; it's the design process that went into making it. Check out the Design Principles [cafeconleche.org] for a good read.
Craig
ANTLR for writing lexers and parsers (Score:1)
(Tree parsers parse the syntax tree generated by the parser (optional) for doing multi-pass semantic / compile checks, for example.)
Once you've learned the techniques for DSLs you start to use them everywhere, especially in large architectural design).
JNT (Score:2)
Might look around at NIST [nist.gov].
A few years ago I saw a nice presentation from one of the NIST people about getting the best Java performance for scientific computational tasks.
Xineo (Score:1)
http://software.xineo.net/oax.jspx [xineo.net]
And those too: (Score:1)