Reputation: 599
I know there are similar questions posted before and I went through those but still its not working for me.
I am creating a sample JMS test class (chat application) and uses javaee.jar and javax.jms.jar. I can test it through Eclipse IDE and it works fine. But I am trying to run through command prompt so I can run multiple windows.I managed to compile the Chat.java file and it created the Chat.class. But when i try to run it, I get could not find or load main class
. These are the commands I used:
From the src/domain
folder:
javac -classpath javaee.jar;javax.jms.jar Chat.java
---- this created Chat.Class inside domain folder where domain is the package name
The I ran the following command from src
folder
java -classpath javaee.jar;javax.jms.jar domain.Chat
---- this gives me the could not find or load main class domain.Chat
error message
But when I run without the -classpath parameter(java domain.Chat
), it reads the main() and gives me different error since it cant find the jms jar files.
E:\eclipse\Spring\JMSChat\src>java domain.Chat
Exception in thread "main" java.lang.NoClassDefFoundError: javax/jms/MessageList
ener
So basically it finds the Chat.class
file when I don't pass in the classpath parameter and it cannot find the class when I use the classpath to add the jars. I tried running it from within domain folder as well as from src folder, but no luck. Any clue what I am doing wrong?
Thanks in advance.
Upvotes: 0
Views: 7611
Reputation: 15508
1) You can run multiple instances of the app from Eclipse, and you can check their outputs by cycling through their allocated consoles by clicking on the arrow next to the console icon
2) try running from your source folder java -classpath .;javaee.jar;javax.jms.jar domain.Chat
"." means current dir
Upvotes: 0
Reputation: 159754
Try this
java -classpath javaee.jar;javax.jms.jar;. domain.Chat
By default java
uses the current directory in the classpath. When you use the -cp
flag, it does not so the path to domain.Chat
is not found.
Upvotes: 3