• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Using simple java program i want to communicate with MQ

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Websphere5.1 MQ.

In my application, i am able to communicate with MQ using application server.

But, my requirement is without using application server, i want to communicate with MQ.

Using simple java program i want to communicate with MQ

While i am trying this, I am getting the following error

JNDI lookup failed: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

I want to know what are the step need to be done to communicate with MQ using simple java program uisng main method.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your error message basically means you have not configured your Context's environemnt properly. Have a read though the JNDI tutorial to learn the basics. Check the MQSeries documentation fo the corret values to use.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BTW, You don't need to get your MQ connections from JNDI if you are reading from a simple java program without App Server, you can access like this in a very simple way.

MQEnvironment.hostname = "HOST_NAME"; // host to connect to
MQEnvironment.port = 1414; //Input your port
MQEnvironment.channel = "CHANNEL_NAME"; // Case Sensitive
MQQueueManager qMgr = new MQQueueManager("MYQMGR");

//Replace with the required option
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT ;


MQQueue simple_queue = qMgr.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE",openOptions,null,manager,null,
 
He got surgery to replace his foot with a pig. He said it was because of this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic