Solved

Java, which jar file will be loaded

Posted on 2014-01-16
4
392 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 34

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 34

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
micro services vs rest web services 16 103
ForLoop Example 3 48
Oracle SQL syntax check  without executing 6 50
hibernate example issues from command prompt 10 40
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ā€¦
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.

806 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