2

I have maven project which contain two jars jersey-core-1.18.1 and jaxrs-api-3.0.1.Final and both jar have Response.java class with inside same package javax.ws.rs.core.Response

Some places i want to use jersey-core-1.18.1 and some places i will want to use javax.ws.rs.core.Response.

But eclipse showing only one import javax.ws.rs.core.Response and this is referring to jersey-core-1.18.1.

What changes i have to make so both jar file import will available?

Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202
  • Related: [Import conflict - because of same package structure](http://stackoverflow.com/q/34609090) – Basilevs Jan 08 '16 at 05:56
  • I would not call that a good idea. You'll have to *start* by writing a class loader (and unloader). – Elliott Frisch Jan 08 '16 at 05:56
  • Possible duplicate of [Dealing With Duplicate Fully Qualified Names](http://stackoverflow.com/questions/12823048/dealing-with-duplicate-fully-qualified-names) – Basilevs Jan 08 '16 at 05:58
  • @ElliottFrisch Actually I have to test Retry Mechanism which is not available with Jercey then only i will totally delete Jercey jars and refer Resteasy jar .But for testing purpose with my project i have to use it like this. – Subodh Joshi Jan 08 '16 at 05:58

1 Answers1

2

The first jar on the build path at execution time which has the class needed "wins". What you are doing is very dangerous because any reordering of jars on the classpath after you built it will change the behaviour of your program.

Therefore you should only have a single version of the classes in question on your build path (even though they may exist in several copies). Upgrade or downgrade your current artifacts or find others which allow this.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347