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[])
{
try
{
SimpleEmail email = new SimpleEmail();
email.setDebug(true);
email.setHostName("smtp.myhost.com");
email.addTo("[email protected]", "foo bar");
email.setFrom("[email protected]", "john doe");
email.setSubject("Test message");
email.setMsg("This is a simple test of commons-email");
email.send();
}
catch(Exception e) { e.printStackTrace(); }
System.out.println("ok");
}
}
The JAR file downloaded from the apache commons website is in the same
directory of Main.java and is name email.jar .
I compile this way : javac -cp email.jar Main.java
No error, I execute : java Main.java
I have this error :
Exception in thread "main" java.lang.NoClassDefFoundError: Main/java
Caused by: java.lang.ClassNotFoundException: Main.java
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: Main.java. 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: [email protected]
For additional commands, e-mail: [email protected]