Solved

Java, which jar file will be loaded

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
return in catch statement 1 40
wordcount challenge 11 78
bitbucket vs gitbucket 3 35
micro services vs rest web services 16 53
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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.
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now