Solved

Java, which jar file will be loaded

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
what is the main difference between git clone and fetch ann pull and push commands 2 73
Java JRE greater than 1.6 5 50
more than one jdk and one jre 1 33
oracle 11g 23 50
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

920 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

15 Experts available now in Live!

Get 1:1 Help Now