0

Till now we are using myeclipse to for development.

Now we started development using eclipse keplar.

My first problem is jars are not deployed in webapps lib directory which we solved by referring [link] Adding 3rd party jars to WEB-INF/lib automatically using Eclipse/Tomcat

but every time if want to add third party jar's dependency then we have to add in build path and Deployment Assembly

so please let me know if there is any workaround to add entry only in build path and this jar is automatically deployed in tomcat directory.

Thanks in advance.

Community
  • 1
  • 1
Darshan Patel
  • 3,176
  • 6
  • 26
  • 49
  • right click on project>build path > export/import > add libs – Sachin Verma Jan 01 '14 at 07:24
  • @SachinVerma thanks for reply But i think this option is for exporting war/jar or other file not for running project directly from eclipse.. correct me if i am wrong.. – Darshan Patel Jan 01 '14 at 07:37
  • i think you want to know how to add jars in eclipse.If this is your requirement then check this http://stackoverflow.com/questions/19179687/java-lang-classnotfoundexception-in-jdbc-program – SpringLearner Jan 01 '14 at 07:37

3 Answers3

2

Suppose here we have an example to add an external jar using eclipse kepler:

suppose we have have a project here RIGHT-CLICK on it and select its PROPERTIES...

enter image description here

Then click on JAVA-BUILD-PATH..

enter image description here

click on LIBRARIES tab and click on ADD-EXTERNAL-JARS...

enter image description here

now select whatever you want to add an external jar or API and click ok

enter image description here

after taht you will see on libraries CONGRATS you have successfully added a jar file..

enter image description here

Rajendra arora
  • 2,186
  • 1
  • 16
  • 23
  • LoL.. nice one buddy!! – Sachin Verma Jan 01 '14 at 08:23
  • @crazydevloper exactly i done that but when i start server and calling this servlet ten it gives class not found exception which is solved using [link] Adding 3rd party jars to WEB-INF/lib automatically using Eclipse/Tomcat but why i am suppose to add jar entry in two different page one in build path and another in Deployment Assembly i want to avoid that part.. – Darshan Patel Jan 01 '14 at 08:24
  • or If you can access your server,place the jar file in the lib dir in your server.Though this is not a good way to do about things,you could resolve your issue.I think here must be some prblmens in the jar – Rajendra arora Jan 01 '14 at 08:55
1

go to Run > Run Configuration create a configuration node if there isn't any, go to the Classpath tab and add whatever you want: Projects, JARs, External JARs, then they would be deployed, when you run your tomcat.

Mehran Hatami
  • 12,723
  • 6
  • 28
  • 35
  • Thanks @MehranHatami i tried this as you said but every time if i want to add new jar then i have to made two entry one in build path and another in run configuration i want to achieve only one configuration is used for compilation, deployment and running application – Darshan Patel Jan 01 '14 at 07:52
  • I have gone through the exact same nightmare several times, all this problems have been solved once I moved to `Maven`. – Mehran Hatami Jan 01 '14 at 07:56
  • Yes we aware about maven but this our last option – Darshan Patel Jan 01 '14 at 08:01
0

Darshan,

As you have added a "myeclipse" tag, I guess you are using MyEclipse. In this case, just use the deployment assembly to add dependencies, whether it is another project or an external jar file. When added this way, it will automatically be added to the build path (you will see it in the "Web App Libraries" container in the Package Explorer, under the project).

The MyEclipse developers are looking at the possibility of synchronizing the deployment assembly when adding to the build path directly but it's not clear that this is possible. So, just use the deployment assembly, in future, for adding dependencies to web projects.

Tony Weddle
  • 2,081
  • 1
  • 11
  • 15
  • i have not added myeclipse tag BhavikAmbani edited my question and he add this flag.. sorry for misunderstanding.. – Darshan Patel Jan 02 '14 at 04:17
  • OK. Well, if you're using the eclipse web tools, they are the basis for similar tools in MyEclipse, so it may work the same way. Try adding only to the deployment assembly and see if the dependency appears in the build path automatically. If so, then only use the deployment assembly in future to add jar and project dependencies. – Tony Weddle Jan 06 '14 at 09:03
  • Thanks for suggestion @TonyWeddle. I tried this before asking question but not working. – Darshan Patel Jan 06 '14 at 09:24
  • I just tried this on eclipse JEE. Adding an external archive (JAR) to the deployment descriptor does add the file to the Web App Libraries container, which is in the build path and visible in the Project Explorer under Libraries (which is under Java Resources). Sorry, I have no idea why it's not working for you, though I only tried it on 4.2, not 4.3, so a bug might have been introduced there. I suggest you ask on the eclipse user forums. – Tony Weddle Jan 08 '14 at 04:45