Hibernate Hello World Program in Eclipse
Mates, now am going to show like how to execute the previous hibernate program in Eclipse IDE to make our world little easy. You might be fresher or not aware of executing java programs in the eclipse what ever just follow these setps…..
1. Download Eclipse IDE for Java EE Developers
2. Unzip and open Eclipse
3. Now create a new java project like, File –> New –> Java Project
4. See now it will opens one window, there give the project details like project name and keep the other details as it is.. and press Finish
5. so you have been created one new java project and at the left side you must see like.. (Before this, make sure you have been selected navigator view in windows –> show view –> Navigator)
6. create the following files in the src folder..
- In the src create sub folder with name str(like package) , and create 2 xml files with names hibernate.cfg.xml and Product.hbm.xml
- In the str folder create 2 more java files with names, Product.java and ClientForSave.java
- so the final directory structure will be..
Actually our work is to do every thing in src folder and Eclipse will automatically create and copies all the related .classes files, folders and .xmls in bin folder, what am saying is as a programmer we no need to touch bin folder, ours is src only
7. Now copy and paste the code into the files in the eclipse..
8. Finally double click on ClientForSave.java so that file will be opens, then right click on the code and Run As –> Java Application
9. Now see the console.., it will be like
That’s it…, you are done..!!
And finally in the database
And mates, this is the same process for the hibernate applications, actually its little time taking for me to give all the examples in the Eclipse so from the next example am going to give related files only, you can carry on with Ecliplse
Sivateja Kandula [ Java/J2EE Developer & Web Designer ]
Founder of Java4s.com - Indian, lives in United States. You can contact me at firstname.lastname@example.org