commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alfred Sawaya <>
Subject Error while executing code with SimpleEmail class
Date Fri, 19 Jun 2009 11:39:35 GMT
Hello world !

I'm trying to use the SimpleMail class but I don't manage to send my mail.
I'm not experienced in Java, and I think it's about how I include the
jar file to my program.

So, this is the source :

    import org.apache.commons.mail.SimpleEmail;
    public class Main
         public static void main(String args[])
                SimpleEmail email = new SimpleEmail();
                email.addTo("", "foo bar");
                email.setFrom("", "john doe");
                email.setSubject("Test message");
                email.setMsg("This is a simple test of commons-email");
            catch(Exception e) { e.printStackTrace(); }

The JAR file downloaded from the apache commons website is in the same
directory of and is name email.jar .
I compile this way : javac -cp email.jar
No error, I execute : java
I have this error :

    Exception in thread "main" java.lang.NoClassDefFoundError: Main/java
    Caused by: java.lang.ClassNotFoundException:
        at Method)
        at java.lang.ClassLoader.loadClass(
        at sun.misc.Launcher$AppClassLoader.loadClass(
        at java.lang.ClassLoader.loadClass(
        at java.lang.ClassLoader.loadClassInternal(
    Could not find the main class:  Program will exit.

Same error if I try : java -cp email.jar Main

Where do I do wrong ?

Thanks folk !


     .:: Alfred Sawaya ::.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message