• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No classdef found error

 
Jayashree Gopal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am using the JavaMail API for the first time. I have written a program which uses the JavaMail API to write a message. This file compiles properly but when i run it thru the command line it gives me a NoClassDefFoundError. I have ensured tht the .class file is in the same directory from where i am trying to access it.
I have stored the .class file under e:\Prog\javamail\demos and while using the command line i go to this path and give the command line.
I am attaching the code herewith:
Please let me know if there is any error in this code:
import javax.mail.Session;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class MailMessage
{
public static void main(String args[])
{
try
{
String host = args[0];

Properties props = new Properties();
props.put("mail.http.yahoo.com",host);

Session newSession = Session.getInstance(props,null);

MimeMessage message = new MimeMessage(newSession);

message.setFrom(new InternetAddress("gjaya26@rediffmail.com"));

message.setRecipients(Message.RecipientType.TO,"gjaya26@yahoo.com");

message.setSubject("Hello");

message.setText("Using JavaMail for the first time");

//Transport transp = new Transport(newSession,host);

Transport.send(message);
}

catch(AddressException e1)
{
e1.getMessage();
}

catch(Exception e)
{
e.getMessage();
}

System.out.println("Message sent Successfully");
}
}
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The mail.jar (or mailapi.jar) file is in the same directory as MailMessage.class?

If it is, try :

java -cp mail.jar MailMessage

As a second note, simply calling e.getMessage() won't show anything. is what you (probably?) want.
[This message has been edited by Mike Curwen (edited December 19, 2001).]
 
Jayashree Gopal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
The mail.jar has been added to the classpath and is present in the root directory of javamail. I tried to run the same program keeping it in the same directory as that of mail.jar .However,the problem still remains unsolved.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
activation.jar as well?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic