1

I'm currently doing this tutorial on Hibernate over here http://www.javatpoint.com/example-to-create-hibernate-application-in-eclipse-ide and I downloaded the hibernate.zip and oracle.jar files, tried to add them to the project through right clicking on the project -> build path -> configure build path -> add external jars and selecting the jars, but they are not getting imported in a "Referenced library", they just appear as stand alone .jar files that don't to anything and can't be referenced to.

How can I make them "go" into the Referenced Libraries? That folder isn't even created when I import the jar files.

Thanks!

Robert Ruxandrescu
  • 627
  • 2
  • 10
  • 22

3 Answers3

0

You should use Maven for handling your dependencies and let Eclipse & Maven together take care of downloading and organizing your dependencies. You won't even need to download the jar files manually anymore.

This is the basic usage of Maven with Eclipse:

http://www.tech-recipes.com/rx/39279/create-a-new-maven-project-in-eclipse/

In case you're totally new to Maven, i'm happy to provide further help via comments.

  • Yes, I am totally new to Maven, it is already installed in my Eclipse here at work... so Maven should/would automatically download the necessary jar files for this particular project? If so, how? – Robert Ruxandrescu Apr 14 '16 at 09:03
  • Maven is basically a build tool like ANT and Make - it uses a file to describe your project (this file is called pom.xml - POM stands for Project Object Model). In this pom.xml basically you provide brief info about your project (project name, source code location, etc) and most importantly, the dependencies of your project. So, assuming you're using hibernate in your project, you'll just need to add the dependency ` org.hibernate hibernate-core 5.1.0.Final ` and Maven will take care of downloading... – Laszlo Merczel Apr 14 '16 at 09:12
  • ... the jar files you need. Now used together with Eclipse, Eclipse will set up the project for you based on the settings you've provided in the pom.xml file - e.g. it'll set up the Referenced libraries, etc. Here's a small series of video tutorials about Maven basics (not mine, but good anyway!) - https://www.youtube.com/watch?v=al7bRZzz4oU&list=PL92E89440B7BFD0F6 Parts 01 - 04 will get you covered with what you need for a quick start. – Laszlo Merczel Apr 14 '16 at 09:15
  • Finally, part 9 of those video series will show how you're integrating Maven with Eclipse. https://www.youtube.com/watch?v=uv9tXFrTLtI This whole stuff might sound like an overkill to you, but trust me, it'll worth the invested time, especially if you'll be working with larger projects later on where a lot of jars are involved. Mixing and matching dependency jars manually can be a nightmare, trust me. – Laszlo Merczel Apr 14 '16 at 09:18
  • Well, I added the tags in the pom.xml file, but the opening tag is underlined in red... lol I put it as the last tag. – Robert Ruxandrescu Apr 14 '16 at 09:22
  • You're probably putting it to the wrong place. Check out video #4 from the series, it shows how to do it properly. – Laszlo Merczel Apr 14 '16 at 09:24
  • Oh, it was wrapped in a ... tag. – Robert Ruxandrescu Apr 14 '16 at 09:28
  • Now it "works" but the hibernate objects are still not imported in any way – Robert Ruxandrescu Apr 14 '16 at 09:29
  • In this particular case, I have to add these jars: http://www.javatpoint.com/src/hb/hibernatejar.zip http://www.javatpoint.com/src/jdbc/ojdbc14.jar You're saying Maven will automatically take care of all these (the first one is a zip file with many jars in it)? I'll watch the videos now. – Robert Ruxandrescu Apr 14 '16 at 09:34
  • Just checked out that ZIP file - it contains a very old version of hibernate and all of its dependencies. If you add ` org.hibernate hibernate-core 5.1.0.Final ` to pom.xml, it imports a recent version of hibernate complete with its dependencies. Exactly what objects are missing? – Laszlo Merczel Apr 14 '16 at 11:28
  • I created the new project, worked bad, so I deleted it from Eclipse. That deleted everything I worked in the last 2 weeks with no possibility of recovery. Great start of my career. – Robert Ruxandrescu Apr 14 '16 at 11:32
  • Jesus... Sorry to hear that dude. – Laszlo Merczel Apr 14 '16 at 12:24
  • Yeah it was really weird... apparently it created dependencies to external libraries from here, from work, that were deleted with the project. In Linux, apparently they don't go to the trash if you delete them from Eclipse. Now I'm trying to recreate what I lost and ... at least it's an "opportunity" to see what I learned. – Robert Ruxandrescu Apr 15 '16 at 13:37
0

I suppose your Eclipse perspective is selected "Resource", not "Java" or "Java EE". enter image description here

After you change the perspective to "Java", you will see the Referenced Libraries.

Eric Wei
  • 61
  • 6
  • I did change the perspective, but the projects look the same. It's obvious that there's an error when I import the jar files since they can't be accessed or used. The just "sit there". – Robert Ruxandrescu Apr 14 '16 at 09:25
0

Check this Option : Right click Project >> Show In >> Project Explorer

Dana
  • 35
  • 1
  • 7