Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to give priority to a jar file in eclipse classpath?

There is a class file TagAttributeInfo which is under two of my jar files.

j2ee-6.1.jar,servlet-api-2.3.jar .

Now i need that class to be called from j2ee-6.1.jar but in runtime ,it is taking the class of servlet-api-2.3.jar,which i don't want. Can anybody help me to prioritize the jar file in class path so that i will give first priority to j2ee-6.1.jar.

like image 489
BOSS Avatar asked Sep 30 '11 08:09

BOSS


3 Answers

You move it up in the classpath order (right click on the project, select Build Path, followed by Configure Build Path and then Order and Export)

like image 130
Aravind Yarram Avatar answered Oct 16 '22 07:10

Aravind Yarram


  • Go into your Project Properties > Build Path.
  • In the Order and Export tab, find j2ee-6.1.jar and press the Up button to move it higher up in the class path order. Keep pressing Up until it is above servlet-api-2.3.jar.
  • Finally press OK.
like image 6
dogbane Avatar answered Oct 16 '22 07:10

dogbane


The first jar that it finds on the classpath that has the class it's looking for will be used. So you can prioritize your class by putting its jar at the beginning of the classpath.

How exactly you would do this in Eclipse I'm not sure, but there's probably some list of project dependencies that correspond to the jars on the classpath, and hopefully you can order the elements on that list and put your jar on the top. Try looking for it in the project settings panel.

like image 3
Nate W. Avatar answered Oct 16 '22 08:10

Nate W.