?
Solved

Java, which jar file will be loaded

Posted on 2014-01-16
4
Medium Priority
?
436 Views
Last Modified: 2014-01-17
This site:

http://pic.dhe.ibm.com/infocenter/wmqv7/v7r1/index.jsp?topic=%2Fcom.ibm.mq.doc%2Fjm10330_.htm

says that

 The manifest of the JAR file com.ibm.mqjms.jar contains references to
 most of the other JAR files required by WebSphere MQ classes for JMS
 applications, and so you do not need to add these JAR files to your
 class path.

Open in new window


So in the MANIFEST of my jar I have the following manifest classpath:

    Class-Path: /opt/mqm/java/lib/com.ibm.mqjms.jar

Open in new window


In the com.ibm.mqjms.jar, it contains the following MANIFEST classpath

    Class-Path: jms.jar com.ibm.mq.jmqi.jar dhbcore.jar rmm.jar jndi.jar l
     dap.jar fscontext.jar providerutil.jar CL3Export.jar CL3Nonexport.jar

Open in new window


My question is:  when the com.ibm.mqjms.jar starts looking for the jms.jar (or other jar),
where will it be looking ?  (or at least looking first?

In the jar file itself,or on the /opt/mqm/java/lib
0
Comment
Question by:Los Angeles1
  • 2
4 Comments
 

Author Comment

by:Los Angeles1
ID: 39786365
... and could you please provide a link as to why it would load from one source and not the other ?

Thanks
0
 
LVL 36

Accepted Solution

by:
Gary Patterson earned 1332 total points
ID: 39787115
Jars aren't loaded.  Classes contained in jars are loaded as they are called for by the application.  When an application calls for a class, there are a set of rules that determine the search hierarchy.

Basic Java classloading rules:

http://docs.oracle.com/javase/tutorial/ext/basics/load.html

and Websphere classloading:

http://www.redbooks.ibm.com/redpapers/pdfs/redp4581.pdf

I'm not sure I understand the question.  

What do you mean by "one location not the other"?

The only reference I see above to jms.jar is the relative reference in the manifest classpath for com.ibm.mqjms.jar.  That is a relative reference, which means to look in the same folder as the com.ibm.mqjms.jar file - /opt/mqm/java/lib/

And what do you mean by "in the jar file itself?  What jar file?  By default java can't load a "jar in a jar" unless you use a custom classloader.

- Gary
0
 
LVL 1

Assisted Solution

by:Smart_Kid
Smart_Kid earned 668 total points
ID: 39787683
it will look in /opt/mqm/java/lib/  itself.
0
 
LVL 36

Assisted Solution

by:Gary Patterson
Gary Patterson earned 1332 total points
ID: 39788918
It will look in /opt/mqm/java/lib/  itself - unless the class is found first by another classloader higher in the hierarchy.  

For example, if jms.jar is found in the Java Extensions directory, or the Websphere Extensions directory, the requested class will be loaded from that copy of jms.jar, and not by the application classloader based on the relative reference listed in the jar manifest.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question