Steve
Steve

Reputation: 2818

Where To Put JAR Files To Avoid Conflicts?

Windows XP Pro WebLogic 11g Tomcat 7 JDK 1.6

I've been putting supplemental JAR files in

JAVA_HOME/jre/lib/ext ( a JDK installation )

for years. It is much more convenient than altering my CLASSPATH and everything I develop has access to one set of stuff in one place.

I need a different or better approach though.

I recently installed WebLogic 11g on on my computer. Since I do not like having multiple JDKs or JVMs on my machine I set my JAVA_HOME variable to point to there.

I then put a servlet-api.jar there to compile my webapps. All was well.

Then I installed Tomcat 7. Tomcat 7 has its own servlet-api.jar in CATALINA_HOME/lib. Having a servlet-api.jar in CATALINA_HOME/lib and one in JAVA_HOME/jre/lib/ext causes Tomcat 7 to throw errors. However, I need one in JAVA_HOME/jre/lib/ext to compile my webapps.

Is there a more graceful solution than deleting servelt-api.jar from CATALINA_HOME/lib ?

Thanks

Upvotes: 1

Views: 1465

Answers (2)

Edwin Dalorzo
Edwin Dalorzo

Reputation: 78619

From the Java Tutorial: The Extension Mechanism:

The extension mechanism provides a standard, scalable way to make custom APIs available to all applications running on the Java platform. Java extensions are also referred to as optional packages. This trail may use both terms interchangeably.

Extensions are groups of packages and classes that augment the Java platform through the extension mechanism. The extension mechanism enables the runtime environment to find and load extension classes without the extension classes having to be named on the class path. In that respect, extension classes are similar to the Java platform's core classes. That's also where extensions get their name -- they, in effect, extend the platform's core API.

Since this mechanism extends the platform's core API, its use should be judiciously applied. Most commonly it is used for well standarized interfaces such as those defined by the Java Community Process, although it may also be appropriate for site wide interfaces.

Upvotes: 2

Maarten Bodewes
Maarten Bodewes

Reputation: 94018

Don't put the Jar in /ext, but compile against your actual EE framework. In that way you won't run into problems when the version of the .jars delivered with your Tomcat (or other EE installation) changes. So don't put the .jar in ext anymore and change the build path to your actual EE environment.

Upvotes: 1

Related Questions