Author |
Message
|
sebastian |
Posted: Tue Oct 19, 2004 9:48 am Post subject: package com.ibm.mq does not exist |
|
|
 Centurion
Joined: 12 Nov 2003 Posts: 110 Location: Philadelphia
|
I am a Perl programmer trying to code in Java with MQSeries. The Java JDK, MA88 libraries are loaded and have the MQ client on my workstation.
I found a simple MQ code example and am trying to compile into bytecode but I get the error "package com.ibm.mq does not exist."
I have reduced my source code to this:
// MQSeries Java sample application
//
import com.ibm.mq.*; // Include the MQSeries classes for Java package
But I get the same error. I can see there are files com.ibm.mqbind.jar, com.ibm.mq.jar and com.ibm.mqjms.jar in my directory.
What am I doing wrong?
Any help is greatly appreciated.
thanks
Sebastian _________________ sebastian signature |
|
Back to top |
|
 |
RogerLacroix |
Posted: Tue Oct 19, 2004 9:59 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
RTM, did you update your CLASSPATH as per the manual? Read chapter 2 of the WMQ Using Java manual (page 11 in particular).
Regards,
Roger Lacroix _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Oct 19, 2004 10:24 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Also, do not use MA88 for any queue managers that are newer than 5.2.
Download the MQSeries Client installation package, and install the Java Messaging from the custom options of the installer.
Or use your MQServer CD to do a custom install of the Java Messaging component. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
JLRowe |
Posted: Tue Oct 19, 2004 12:18 pm Post subject: |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
Download a free IDE called eclipse from www.eclipse.org, it may even convert you to the java fold... |
|
Back to top |
|
 |
RogerLacroix |
Posted: Tue Oct 19, 2004 1:53 pm Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Hi,
I usually stay out of IDE wars because they can get quite heated. But I fully agree that Eclipse will make your Java / MQ development process much easier.
Regards,
Roger Lacroix _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
sebastian |
Posted: Tue Dec 28, 2004 7:46 am Post subject: |
|
|
 Centurion
Joined: 12 Nov 2003 Posts: 110 Location: Philadelphia
|
I updated my CLASSPATH definition per the WMQ Using Java Manual suggestions and I am still getting the error "package com.ibm.mq" does not exist.
my CLASSPATH =
CLASSPATH=mq_root_dir\java\lib\com.ibm.mq.jar;mq_root_dir\java\lib\connector.jar;mq_root_dir\tools\java\base;mq_root_dir\java\lib\jta.jar;
Is there something else I could be missing?
Any suggestions are welcome,
Seb _________________ sebastian signature |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Dec 28, 2004 8:02 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
What is the command you are running to compile?
What OS are you running on? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
sebastian |
Posted: Tue Dec 28, 2004 9:53 am Post subject: |
|
|
 Centurion
Joined: 12 Nov 2003 Posts: 110 Location: Philadelphia
|
"javac MQSample.java"
The source code is saved as "MQSample.java"
I am running on Windows 2000.
The error message I get is: "MQSample:12: package com.ibm.mq does not exist"
the java code lists:
import com.ibm.mq.*; // include the MQSeries classes for java package
I did define in CLASSPATH=C:\Program Files\IBM\Websphere MQ\Java\lib\com.ibm.mq.jar
Seb _________________ sebastian signature |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Dec 28, 2004 10:29 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
How did you alter classpath? Using the Environment control pane? Or using "set" in the command shell?
If you used the Environment Variables pane, did you then restart your system? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Dec 28, 2004 11:17 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You are still missing a number of jars in your mq/java/lib directory.
Remember as well that in windows the path variable must grant access to mq/java/lib and mq/java/lib/jdbc. On Unix this should be on the LIBPATH_LD (check variable name as it is system dependant (AIX, Solaris, HP etc...)).
Just for safety include all the jar files in mq/java/lib to your classpath
Enjoy  |
|
Back to top |
|
 |
RogerLacroix |
Posted: Tue Dec 28, 2004 7:38 pm Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
sebastian,
Since you listed your path with a backslash '\' , I'll assume that you are on Windows.
First off, the MQ Java libs are NOT installed by default when you install MQ. When you did the install of MQ, did you select a 'Custom Install'??
Secondly, please verify that the JAR files are actually in that particular directory ( mq_root_dir\java\lib ). There should be an actual file called com.ibm.mq.jar in mq_root_dir\java\lib\ (where mq_root_dir is something like C:\Program Files\IBM\WebSphere MQ )
Finally, when you do the custom install and select Java libraries then the Windows Installer will update your CLASSPATH automatically for you. But you need to REBOOT the Windows box to pick up the changes. (It does NOT force it.)
Hope that helps.
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
sebastian |
Posted: Wed Dec 29, 2004 6:07 am Post subject: |
|
|
 Centurion
Joined: 12 Nov 2003 Posts: 110 Location: Philadelphia
|
Thank you for your responses. I did run the custom install and checked that the .jar files were added correctly and then rebooted.
I am trying to run the MQSample program from page 73 in the WMQ Using Java manual.
I can compile it fine and it creates the .class file but when I try running the program, I get the error
java MQSample
Exception in thread "main" java.lang.NoClassDefFoundError: MQSample
Since there is no code line specified, I think there is still something wrong in my MQ setup. Am I still missing something?
any help is appreciated,
Seb _________________ sebastian signature |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed Dec 29, 2004 9:20 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
First, you said you were getting this error:
sebastian wrote: |
The error message I get is: "MQSample:12: package com.ibm.mq does not exist" |
Which is a CLASSPATH problem.
Now you are reporting the following error:
sebastian wrote: |
Exception in thread "main" java.lang.NoClassDefFoundError: MQSample |
This is total different. Java (JVM) is complaining that it cannot find 'main' in your program. Did you copy MQSample from page 71 (applet version) or from page 73 (with main). It looks like you copied the wrong program.
Regards,
Roger Lacroix _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
vennela |
Posted: Wed Dec 29, 2004 9:24 am Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
Even if he copied the right program, the classfile MQSample may not be in the CLASSPATH.
Do
Code: |
SET CLASSPATH=%CLASSPATH%;.;..; |
and run your program form the directory where your program is. |
|
Back to top |
|
 |
sebastian |
Posted: Wed Dec 29, 2004 10:46 am Post subject: |
|
|
 Centurion
Joined: 12 Nov 2003 Posts: 110 Location: Philadelphia
|
Roger, I see the line "public static void main(String args[]) {" included in the code. Since the code is not too long, I also attached it below.
Vanella, I tried running your SET statment before running my MQSample application and got the following:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/resource/ResourceException
at MQSample.<init><MQSample.java:29>
at MQSample.main<MQSample.java:21>
Did you mean to run this from DOS or to code it into the java code itself?
// ======================================================================
// Licensed Materials - Property of IBM
// 5639-C34
// (c) Copyright IBM Corp. 1995, 1999
// ======================================================================
// MQSeries classes for Java sample application
//
// This sample runs as a Java application using the command :- java MQSample
import com.ibm.mq.*; // Include the MQSeries classes for Java package
public class MQSample
{
private String qManager = "PR01u64D"; // define name of queue
// manager to connect to.
private MQQueueManager qMgr; // define a queue manager
// object
public static void main(String args[]) {
new MQSample();
}
public MQSample() {
try {
// Create a connection to the queue manager
qMgr = new MQQueueManager(qManager);
// Set up the options on the queue we wish to open...
// Note. All MQSeries Options are prefixed with MQC in Java.
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF |
MQC.MQOO_OUTPUT ;
// Now specify the queue that we wish to open,
// and the open options...
MQQueue system_default_local_queue =
qMgr.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE",
openOptions);
// Define a simple MQSeries message, and write some text in UTF format..
MQMessage hello_world = new MQMessage();
hello_world.writeUTF("Hello World!");
// specify the message options...
MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the // defaults,
// same as MQPMO_DEFAULT
// put the message on the queue
system_default_local_queue.put(hello_world,pmo);
// get the message back again...
// First define a MQSeries message buffer to receive the message into..
MQMessage retrievedMessage = new MQMessage();
retrievedMessage.messageId = hello_world.messageId;
// Set the get message options...
MQGetMessageOptions gmo = new MQGetMessageOptions(); // accept the defaults
// same as MQGMO_DEFAULT
// get the message off the queue...
system_default_local_queue.get(retrievedMessage, gmo);
// And prove we have the message by displaying the UTF message text
String msgText = retrievedMessage.readUTF();
System.out.println("The message is: " + msgText);
// Close the queue...
system_default_local_queue.close();
// Disconnect from the queue manager
qMgr.disconnect();
}
// If an error has occurred in the above, try to identify what went wrong
// Was it an MQSeries error?
catch (MQException ex)
{
System.out.println("An MQSeries error occurred : Completion code " +
ex.completionCode + " Reason code " + ex.reasonCode);
}
// Was it a Java buffer space error?
catch (java.io.IOException ex)
{
System.out.println("An error occurred whilst writing to the message buffer: " + ex);
}
}
} // end of sample _________________ sebastian signature |
|
Back to top |
|
 |
|