I will show how to install Hibernate in this blog post and I will set
up a small database application that can store events in my another
post.Although you can use whatever database and IDE you feel comfortable using, I will use MYSQL and Eclipse IDE. Also I assume that Java is already installed on your system.
You should download the latest production release of Hibernate from the Hibernate website at http://www.hibernate.org/ or http://sourceforge.net/projects/hibernate/files/hibernate3/ and unpack the archive after download.
Note: I have downloaded the latest production release, hibernate-distribution-3.6.6.Final-dist.zip. If there is a newer version when you’re reading this post, I advice you to download and use it.
Create a new Java Project and enter HibernateApplication as project name.
Create lib and src subdirectories in this project. (When you create a new Java Project in Eclipse IDE, src subdirectory will be created automatically.)
Copy JAR files which are listed below, from hibernate distribution that you have downloaded to the lib directory of the “HibernateApplication”project.
Under root directory of the hibernate distrubution:
hibernate3.jar
Under lib/required directory of the hibernate distrubution:
antlr-2.7.6.jar
commons-collections-3.1.jar
dom4j-1.6.1.jar
javassist-3.12.0.GA.jar
jta-1.1.jar
slf4j-api-1.6.1.jar
Under lib/jpa directory of the hibernate distrubution:
hibernate-jpa-2.0-api-1.0.1.Final.jar
Download slf4j-1.6.1.zip file from http://www.slf4j.org/download.html, unpack the archive and copy the slf4j-simple-1.6.1.jar file to lib directory of the “HibernateApplication” project.
slf4j-simple-1.6.1.jar
Additionally, you will need the database driver JAR that Hibernate uses to connect to your database. I use MYSQL Database and it’s database driver jar :
Copy this mysqlconnector.jar to the lib directory of the “HibernateApplication” project
.
Note: You should replace this database driver JAR with a different database driver JAR
After these steps “HibernateApplication” project will look like this:
![HibernateApplication_lib HibernateApplication_lib](http://kaanmutlu.files.wordpress.com/2011/07/hibernateapplication_lib.png?w=640)
Now I will create a User library on Eclipse IDE. Then, I will add all JAR files in the HibernateApplication\lib directory to this User library and add this User library to the project build path.
Click Window–>Preferences on the top menu bar of Eclipse.
![Preferences Preferences](http://kaanmutlu.files.wordpress.com/2011/07/preferences.png?w=640&h=389)
Click Java–>Build Path–>User Libraries and click New button then enter “Hibernate”
as the User library name.
![User Library User Library](http://kaanmutlu.files.wordpress.com/2011/07/user-library.png?w=640&h=637)
Select “Hibernate” User library that we just created and click Add JARS… button.
![Hibernate User Library Hibernate User Library](http://kaanmutlu.files.wordpress.com/2011/07/hibernate-user-library.png?w=640&h=372)
Select all JAR files in the lib folder of the “HibernateApplication” project and click Open button to add all JAR files to “Hibernate” User library.
![AllHibernateJars AllHibernateJars](http://kaanmutlu.files.wordpress.com/2011/07/allhibernatejars.png?w=640&h=400)
Now “Hibernate” User library is ready and we can add this User library to “HibernateApplication” project build path.
![HibernateUserLibrary_Jars_added HibernateUserLibrary_Jars_added](http://kaanmutlu.files.wordpress.com/2011/07/hibernateuserlibrary_jars_added.png?w=640&h=343)
Right click to “HibernateApplication” project and click Build Path–>Add Libraries
![HibernateApplication_Build_Path HibernateApplication_Build_Path](http://kaanmutlu.files.wordpress.com/2011/07/hibernateapplication_build_path.png?w=640&h=499)
Then, select “User Library” and click Next button.
![UserLibrary_selection UserLibrary_selection](http://kaanmutlu.files.wordpress.com/2011/07/userlibrary_selection.png?w=640&h=618)
Finally, select “Hibernate” User library and click Finish button.
![Hibernate_user_library_selection Hibernate_user_library_selection](http://kaanmutlu.files.wordpress.com/2011/07/hibernate_user_library_selection.png?w=640&h=612)
After adding “Hibernate” User library to “HibernateApplication” project, it will look like this:
![Hibernate_User_Library_Finished Hibernate_User_Library_Finished](http://kaanmutlu.files.wordpress.com/2011/07/hibernate_user_library_finished.png?w=640)
Congratulations, you have installed Hibernate on Eclipse IDE
You should download the latest production release of Hibernate from the Hibernate website at http://www.hibernate.org/ or http://sourceforge.net/projects/hibernate/files/hibernate3/ and unpack the archive after download.
Note: I have downloaded the latest production release, hibernate-distribution-3.6.6.Final-dist.zip. If there is a newer version when you’re reading this post, I advice you to download and use it.
Create a new Java Project and enter HibernateApplication as project name.
Create lib and src subdirectories in this project. (When you create a new Java Project in Eclipse IDE, src subdirectory will be created automatically.)
Copy JAR files which are listed below, from hibernate distribution that you have downloaded to the lib directory of the “HibernateApplication”project.
Under root directory of the hibernate distrubution:
hibernate3.jar
Under lib/required directory of the hibernate distrubution:
antlr-2.7.6.jar
commons-collections-3.1.jar
dom4j-1.6.1.jar
javassist-3.12.0.GA.jar
jta-1.1.jar
slf4j-api-1.6.1.jar
Under lib/jpa directory of the hibernate distrubution:
hibernate-jpa-2.0-api-1.0.1.Final.jar
Download slf4j-1.6.1.zip file from http://www.slf4j.org/download.html, unpack the archive and copy the slf4j-simple-1.6.1.jar file to lib directory of the “HibernateApplication” project.
slf4j-simple-1.6.1.jar
Additionally, you will need the database driver JAR that Hibernate uses to connect to your database. I use MYSQL Database and it’s database driver jar :
Copy this mysqlconnector.jar to the lib directory of the “HibernateApplication” project
.
Note: You should replace this database driver JAR with a different database driver JAR
After these steps “HibernateApplication” project will look like this:
![HibernateApplication_lib HibernateApplication_lib](http://kaanmutlu.files.wordpress.com/2011/07/hibernateapplication_lib.png?w=640)
Now I will create a User library on Eclipse IDE. Then, I will add all JAR files in the HibernateApplication\lib directory to this User library and add this User library to the project build path.
Click Window–>Preferences on the top menu bar of Eclipse.
![Preferences Preferences](http://kaanmutlu.files.wordpress.com/2011/07/preferences.png?w=640&h=389)
Click Java–>Build Path–>User Libraries and click New button then enter “Hibernate”
as the User library name.
![User Library User Library](http://kaanmutlu.files.wordpress.com/2011/07/user-library.png?w=640&h=637)
Select “Hibernate” User library that we just created and click Add JARS… button.
![Hibernate User Library Hibernate User Library](http://kaanmutlu.files.wordpress.com/2011/07/hibernate-user-library.png?w=640&h=372)
Select all JAR files in the lib folder of the “HibernateApplication” project and click Open button to add all JAR files to “Hibernate” User library.
![AllHibernateJars AllHibernateJars](http://kaanmutlu.files.wordpress.com/2011/07/allhibernatejars.png?w=640&h=400)
Now “Hibernate” User library is ready and we can add this User library to “HibernateApplication” project build path.
![HibernateUserLibrary_Jars_added HibernateUserLibrary_Jars_added](http://kaanmutlu.files.wordpress.com/2011/07/hibernateuserlibrary_jars_added.png?w=640&h=343)
Right click to “HibernateApplication” project and click Build Path–>Add Libraries
![HibernateApplication_Build_Path HibernateApplication_Build_Path](http://kaanmutlu.files.wordpress.com/2011/07/hibernateapplication_build_path.png?w=640&h=499)
Then, select “User Library” and click Next button.
![UserLibrary_selection UserLibrary_selection](http://kaanmutlu.files.wordpress.com/2011/07/userlibrary_selection.png?w=640&h=618)
Finally, select “Hibernate” User library and click Finish button.
![Hibernate_user_library_selection Hibernate_user_library_selection](http://kaanmutlu.files.wordpress.com/2011/07/hibernate_user_library_selection.png?w=640&h=612)
After adding “Hibernate” User library to “HibernateApplication” project, it will look like this:
![Hibernate_User_Library_Finished Hibernate_User_Library_Finished](http://kaanmutlu.files.wordpress.com/2011/07/hibernate_user_library_finished.png?w=640)
Congratulations, you have installed Hibernate on Eclipse IDE
No comments:
Post a Comment
You can enter queries here...