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?"
For server based applications JMX is a must.
Don't write off log4j.
Spring is very good indeed.
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.
jython
JDOM for processing and manipulating XML, real easy to use.
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
Mozilla's LDAP SDK when doing LDAP work
The pre-1.5 concurrent threading classes
Command-line argument handler library
Log4J logging.
_______
2B1ASK1
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.
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.
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.
"Patterns in Java" in 2 volumes from JWiley...this is midway between the library and DIY. The library may not exactly meet your need and you will spend some time reading code and hacking or building a layer on top of the library. And DIY, as you know, is always started as a Quick and Dirty project that quickly proves less Q and more D than hoped...it is the most work. And a pattern, assuming you find one that fits your needs, brings experience or understanding of the problem to your project that a library has but hides in its code
Personally, I have always longed for someone to do the work of rewriting the great old "Numerical Recipes in C" [Cambridge press] for the Java crowd. [or has it been done but BookPool just forgot to spam me about it?]
SLASHDOT: news for people who can't concentrate on work or have no life at all and got tired of yelling back at the TV.
http://jakarta.apache.org/commons/index.html
Cheers
Commons Logging isn't a logging library, but a logging layer. It has been perpetuated by idiots for idiots. Even the authors admit that it's bad, but they did it to solve a political problem (which logging API to use in an OSS project).
c hr istmas_commons_commons_logging
n g_ revisited
See:
http://www.jroller.com/page/fate/?anchor=cruel_
http://www.jroller.com/page/fate/?anchor=cloggi
One of the easiest ways I've seen to do text IO and processing is to just write some stubbies in Jython - to open a file, write to it, etc. Regex stuff can be simplified this way too. Basically, just a wrapper class.
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 has all the the little things you normally have to write and test yourself.
It has lots of obvious classes that you'd almost expect in the JDK like TeeOutputStream, ByteCountingOutputStream, Cache, and StringUtil.
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
Jetty for web server based projects.. FreeBSD...
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.
A couple of template packages that are good:
Freemarker
Velocity.
And if you need to perform pdf manipulation: Big Faceless Java PDF Library It's not free but it's a really nice package
Reflection helper class
This class lets you do basically any reflection using one line of code (call a method, get/set a protected variable). It caches the Methods and Fields so repeated access is sometimes as little as 1/2 the speed of a statically defined method call. This should be in the JDK core.
DynaBean, RowSetDynaClass and ResultSetDynaClass are IMHO better than any other DAO. They work like java beans. but unlike statically defined java beans they can have arbitrary number of fields. DynaBean is a dynamic-DAO without code gen. the fields are defined according to ResultSetMetadata. if your resultset has 10 columns the bean has 10 fields. if your resultset is from a 10+15 table join you have 25 fields in the bean. you can turn the beans into an xml representation. it lacks compile type field name checking but it throws exception when you get the name wrong. everybody in my team has praised DynaBeans for the duration of their first project of using it, and cursed those who used other forms of DAO code gen.
/ or g/apache/commons/beanutils/RowSetDynaClass.html
http://jakarta.apache.org/commons/beanutils/api
to cache the resultset in memory use RowSetDynaClass
to use a server side cursor use ResultSetDynaClass
C++: As powerful as assembly, and as easy to use as... assembly.
www.junit.org is ofcourse the ultimate library you need, it should be part of Java.
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.
Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
... recently I discovered TableLayout. Most Swing guis I code nowadays use it. Very flexible and much easier to use than GridBagLayout. http://www.clearthought.info/software/TableLayout/
It really depends on what you want to do. But generally my starting points usually are for db related stuff hibernate for many other things stuff from the jakarta project (much of the commons stuff, xerces, log4j and others) and from there usually it becomes rougher, swing you cannot do wrong with the jgoodies stuff from java.net, Karsten Lentzsch has done an excellent work) otherwise it depends on the task and license.
- Log4j (really, reconsider using it, it's the industry standard even with the 1.4 logging stuff, that should tell you something)
- Tomcat for servlets, it's great
- Velocity for a templating engine
- Commons for your utility junk
- Ant for building stuff
I would also recomment as another poster has Doug Lea's concurrency utilities. If you have *anywhere* written an Object.wait() or a Object.notify[all](), then replace it with these libraries.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.
dominionrd.blogspot.com - Restaurants on
If you want to do text templating, but are turned off by JSP, you might want to take a look at Jamon. Jamon templates can received typed parameters, support template inheritance, and a wealth of other features. It's very much inspired from perl's Mason.
fastutil is what Jakarta Commons Collection should've been: an actually competent implementation of truly type safe containers.
MG4J from the same place is pretty interesting too.
Don't forget xmlenc, an XML output library.
It's simple, fast and the memory footprint is negligible. It does not have the overhead of DOM-based solutions.
stating the obvious, no server-side java is complete without a DB!
s evy/snmp/s nmp_package.html
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/
oops, I forgot. we're on /. right, so crypto is a must-have:
these guys know what they're doing, winning awards in a david-vs-goliath arena:
http://www.bouncycastle.org/
Many of my favorites have already been mentioned: junit, jdom, xstream, log4j, and many things from Jakarta Commons.
The other things I use regularly are HttpUnit, a virtual web client and Prevayler, a simple Java persistence framework.
http://www.openmap.org/ Is a great package if you need to do any kind of map display.
It's created by Elliotte Rusty Harold, who is one of the bigwigs in both the XML and Java 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 for a good read.
Craig
If you whip up domain-specific languages (DSLs) often, ANTLR is an excellent tool for writing lexers and parsers and tree parsers.
(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).
Now that wasn't so hard now, was it?
Might look around at NIST.
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.
"Provided by the management for your protection."
humour does not a troll constitute. mabye -1 Unfunny, or -1 overrated(joke has been used too much) but 1 troll? mods put down the crack pipe, or start sharing.
GENERATION 26: The first time you see this, copy it into your sig on any forum and add 1 to the generation.
http://software.xineo.net/oax.jspx
I agree whole heartedly on everything you say. (Except maybe absolutly saying to use hibernate instead of SQL... I've run into sld situation where I wouldn't recommend it.)
/. have any wisdom on Maven? As I understand it, it seems to be an "enterprise" version of ant, where the projects are fractured and co-dependant.
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 find a book, and the website is slightly lacking.
Thanks.
Karma Clown
Howard Lewis Ship of Tapestry fame. Also behind HiveMind.
XStream - xml - to - java and back activemq - jms server xpp3 - xml pull parser 3 eclipse - ide
The Bile Blog 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.
dominionrd.blogspot.com - Restaurants on
I'm surprised no one has mentioned www.dom4j.org yet. JDOM has a place: for the simplest of needs it is good, but dom4j is like a swiss army knife for XML. Check it out.
I also echo the sentiments about using HttpClient, but I find that it needs jTidy to go with it (to turn messy, unbalanced HTML into XML that can be sliced and diced with dom4j's xpath expressions).