Exception in thread "main" java.lang.NoClassDefFoundError: com / ibm / mq / MQException

I get below exceptions when I run my program as below,

java -jar MQprogram.jar

I correctly set the class path, which refers to all the necessary banks, "com.ibm.mq.jmqi.jar" is also mentioned in the class path, which has an MQException.

 `Exception in thread" main "java.lang.NoClassDefFoundError: com / ibm / mq / MQException
 Caused by: java.lang.ClassNotFoundException: com.ibm.mq.MQException
         at java.net.URLClassLoader $ 1.run (Unknown Source)
         at java.security.AccessController.doPrivileged (Native Method)
         at java.net.URLClassLoader.findClass (Unknown Source)
         at java.lang.ClassLoader.loadClass (Unknown Source)
         at sun.misc.Launcher $ AppClassLoader.loadClass (Unknown Source)
         at java.lang.ClassLoader.loadClass (Unknown Source)
         at java.lang.ClassLoader.loadClassInternal (Unknown Source)
 Could not find the main class: com.test.bo.MQprogram.  Program will exit.
 `

I still do not understand where the error is.

+3
source share
2 answers

This is almost always due to a combination of an incomplete client installation and / or a CLASSPATH problem. Many people capture jar files rather than performing a full installation and not necessarily getting all of them. Sometimes they just search for jar files and grab them, regardless of different versions. IBM has extensively refactored Java / JMS classes with V7.0 and has made some updates since then. Starting with version V7.0.1, WMQ can be installed on arbitrary directory paths and several installations on the server. This meant that now there could be several JRE / s, several client installations, etc. This did not affect CLASSPATH so much, but it changed the dependencies such as NLS support, tracking, and other things that the Java classes depend on ./p>

The recommendation is to install the full WMQ client and specify CLASSPATH in the installation directory. If this is not possible, then somewhere install the full client and take a set of standard cans from a well-known installation. Then at least you know that you have all the same versions, etc.

If you decide to install the full client from the IBM distribution, you will get several additional features, such as diagnostics and low-level tracing. It also ensures that service can be applied. For example, if you have a problem fixed in a fix pack, you simply install the fix pack on top of an existing client installation. Fix Pack will not be installed if all you have are jar files.

WMQ clients are available as SupportPacs . You can download one of the following values:

Be sure to use Infocenter for the version of the client you are using!

+3
source

This means that in your CLASSPATH there is no JAR that contains the .class file for com.ibm.mq.MQException .

This is Java 101.

This explains what to do with it.

The search for this link was Google 101.

+1
source

All Articles