views:

52

answers:

2

I'm trying to read a mail from Tomcat 6.0. Whenever I put the byte code and source code of the class MailReader in the same folder(and putting the main method), I can compile and run the class and read mail from command prompt, but when I put that class in the folder WEB-INF/classes of tomcat(by removing main method), I'm getting big fat exception saying:

could not find the main class class: Message Reader. Program will exist

Why is that so? I've already put the jar file activation.jar and mail.jar in lib folder of Tomcat, and I'm trying to run the above class from batch file.

+1  A: 

You have 2 version of the same jar. You need to have it in the single place. You can see this answer for explanation but this is generally often happens on Tomcat especially with things like xml parsers and JDBC drivers. So check WEB-INF/lib and Tomcat/lib for conflicts

DroidIn.net
A: 

I'm unclear as to what you're doing. You say you're trying to read mail from Tomcat but then say you're trying to run from a batch file. I'm guessing (correct me if I'm wrong) that you have your classes in a Tomcat webapp/WEB-INF/classes directory that you're just pointing to in your batch file. In which case Tomcat's behavior wouldn't enter into it, it's just a directory.

The other confusing thing is that you say "removing the main method". If you're trying to run the program on the command line with "java a.b.c.MyClass" then the class MyClass needs a properly defined main method to run. Why are you putting in and removing the main method?

Steve B.