This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Servlets and the fly likes what jar file  add to classpath? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "what jar file  add to classpath?" Watch "what jar file  add to classpath?" New topic

what jar file add to classpath?

Shanthi Mari

Joined: Jul 24, 2005
Posts: 24
When importing javax.jms to java files.What all the jar files do we need to add to the classpath.

Where to get the jar files from?

import javax.jms.*;
import javax.naming.*;
import com.servlets.SubscriptionHelper;

public class LoggingRecevier implements MessageListener {

// Print a weather message when it is received
public void onMessage(Message message) {
try {
if (message instanceof TextMessage) {
TextMessage m = (TextMessage) message;
System.out.println("--- Received log message");
} else {
System.out.println("Received message of type " +
} catch (JMSException e) {

public static void main(String[] args) {

// Defaults
String tcf = "jms/TopicConnectionFactory";
String topic = "jms/Topic";

// You can override these if you like. First connection
// factory name, then topic name.
if (args.length == 2) {
tcf = args[0];
topic = args[1];

// Create a receiver, then set it up to listen for messages
// on the topic. Then wait for messages and print them
// as they come in.
LoggingReceiver wr = new LoggingReceiver();
SubscriptionHelper sh =
new SubscriptionHelper(tcf, topic, wr);

// Wait for publications...
System.out.println("Waiting for publications to topic " + topic);

Sun certified Programmer (SCJP1.4)<br />SCWCD
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

It may be that your servlet container is providing servlet.jar, but you need j2ee.jar. The J2EE jars are all in j2ee.jar, but is often broken down to its sub-parts to make it smaller. Add the j2ee.jar to your WEB-INF/lib or go find the jms.jar and add this instead. Either should be fine.
Shanthi Mari

Joined: Jul 24, 2005
Posts: 24
Thanks a bunch David.
I added the J2EE to the container.
I agree. Here's the link:
subject: what jar file add to classpath?
jQuery in Action, 3rd edition