Solved

Java, which jar file will be loaded

Posted on 2014-01-16
4
403 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 35

Accepted Solution

by:
Gary Patterson earned 333 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 167 total points
ID: 39787683
it will look in /opt/mqm/java/lib/  itself.
0
 
LVL 35

Assisted Solution

by:Gary Patterson
Gary Patterson earned 333 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to see all occupied ports on windows 10 laptop 15 93
iterator/ListIterator approach 17 66
Html split(text) 2 45
Bitwise and to sum elements 2 50
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

739 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