Home arrow Java arrow Page 2 - Installation and Set Up of Hibernate
JAVA

Installation and Set Up of Hibernate


Hibernate is an object/relational mapping service that bridges the worlds of Java objects and relational databases. If this sounds like it might be useful to you, keep reading. This article is excerpted from chapter one of Hibernate A Developer's Notebook, written by James Elliot (O'Reilly; ISBN: 0596006969).

Author Info:
By: O'Reilly Media
Rating: 4 stars4 stars4 stars4 stars4 stars / 8
July 27, 2006
TABLE OF CONTENTS:
  1. · Installation and Set Up of Hibernate
  2. · Getting an Ant Distribution
  3. · Getting the HSQLDB Database Engine
  4. · Getting Hibernate
  5. · Setting Up a Project Hierarchy
  6. · Setting Up a Project Hierarchy: A quick test

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Installation and Set Up of Hibernate - Getting an Ant Distribution
(Page 2 of 6 )

If you’re not already using Ant to manage the building, testing, running, and packaging of your Java projects, now is the time to start. The examples in this book are Ant driven, so you’ll need a working Ant installation to follow along and experiment with variations on your own system, which is the best way to learn.

First of all, get an Ant binary and install it.

Why do I care?

We chose to structure our examples around Ant for several reasons. It’s convenient and powerful, it’s increasingly (almost universally) the standard build tool for Java-based development, it’s free and it’s cross-platform. Many of the example and helper scripts in the current Hibernate distribution are Windows batch files, which don’t do any good for people like me who live in a Unix world. Using Ant means our examples can work equally well anywhere there’s a Java environment, which means we don’t have to frustrate or annoy any readers of this book. Happily, it also means we can do many more cool things with less effort—especially since several Hibernate tools have explicit Ant support, which we’ll show how to leverage.

 I used to wonder why people bothered with Ant when they could use Make. Now that I've seen how well it manages Java builds, I feel lost without it.

To take advantage of all this, you need to have Ant installed and working on your system.

How do I do that?

Download a binary release of Ant from http://ant.apache.org/bindownload.cgi. Scroll down to find the current release of Ant, and download the archive in a format that’s convenient for you to work with. Pick an appropriate place for it to live, and expand the archive there. The directory into which you’ve expanded the archive is referred to asANT_HOME. Let’s say you’ve expanded the archive into the directory/usr/ local/apache-ant-1.5.1; you may want to create a symbolic link to make it easier to work with, and to avoid the need to change any environment configuration when you upgrade to a newer version:

  /usr/local $ ln -s apache-ant-1.5.1 ant

 Once Ant is situated, you need to do a couple of things to make it work right. You need to add itsbindirectory in the distribution (in our example,  /usr/local/ant/bin) to your command path. You also need to set the environment variableANT_HOMEto the top-level directory you installed (in this example,/usr/local/ant). Details about how to perform these steps under different operating systems can be found in the Ant manual, http:// ant.apache.org/manual/, if you need them.

Of course, we’re also assuming you’ve got a Java SDK. Because some of Hibernate’s features are available only in Java 1.4, you’d be best off upgrading to the latest 1.4 SDK. It’s also possible to use most of Hibernate with Java 1.3, but you may have to rebuild the Hibernate JAR file using your 1.3 compiler. Our examples are written assuming you’ve got Java 1.4, and they will need tweaking if you don’t.

Once you’ve got this set up, you should be able to fire up Ant for a test run and verify that everything’s right: 

  ~ $ ant -version
  Apache Ant version 1.5.1 compiled on February 7 2003

What just happened?

Well, not much just yet, but you’re now in a position where you’ll be able to try out the examples we provide later on, and use them as a starting point for your actual Hibernate projects.

If you’re new to Ant, it wouldn’t be a bad idea to read the manual a little bit to get a sense of how it works and what it can do for you; this will help make sense of the build.xml files we start working with in our examples. If you decide (or already know) you like Ant, and want to dig deeper, you can pick up O’Reilly’sAnt: The Definitive Guide (after you finishthis book, of course)!

What about…

…Eclipse, JBuilder, Sun ONE Studio (Forte for Java), or some other Java IDE? Well, you can certainly use these, but you’re on your own as far as what you need to do to get Ant integrated into the build process. (Several already use Ant, so you might be starting out ahead; for the others you might have to jump through some hoops.) If all else fails, you can use the IDE to develop your own code, but invoke Ant from the command line when you need to use one of our build scripts.


blog comments powered by Disqus
JAVA ARTICLES

- Deploying Multiple Java Applets as One
- Deploying Java Applets
- Understanding Deployment Frameworks
- Database Programming in Java Using JDBC
- Extension Interfaces and SAX
- Entities, Handlers and SAX
- Advanced SAX
- Conversions and Java Print Streams
- Formatters and Java Print Streams
- Java Print Streams
- Wildcards, Arrays, and Generics in Java
- Wildcards and Generic Methods in Java
- Finishing the Project: Java Web Development ...
- Generics and Limitations in Java
- Getting Started with Java Web Development in...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 4 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials