Greetings,
I am trying to work through a sample JMS application from the O'Reilly book
Java Message Service (2nd edition). The code from the book is posted at the bottom of this post.
The sample Chat program is very simple. The book mentions that I need to add activemq-all-5.2.0.jar to my classpath. So I used the following command to build the program:
javac -cp "C:\Program Files\Apache Software Foundation\apache-activemq-5.2.0\activemq-all-5.2.0.jar" Chat.java
This works. The class file gets created successfully. However, when I try to run the program, I get an exception. The command I am using to run it is this:
java Chat TopicCF topic1 Fred
Exception in
thread "main" java.lang.NoClassDefFoundError: Chat
Caused by: java.lang.ClassNotFoundException: Chat
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: Chat. Program will exit.
I've literally tried everything that I can think of. I thought maybe it was happening because of the package declaration but I don't think that's it. I've confirmed the directory structure is correct and even removed the package declaration altogether. I've searched endlessly for answers online but I can't seem to get past this.
If anyone could take a look at this, I would appreciate it greatly. I want to continue reading through this book but I've hit a roadblock that I can't seem to get past. Thanks!