aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes No classdef found error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "No classdef found error" Watch "No classdef found error" New topic
Author

No classdef found error

Jayashree Gopal
Greenhorn

Joined: Nov 06, 2001
Posts: 8
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

Joined: Feb 20, 2001
Posts: 3695

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

Joined: Nov 06, 2001
Posts: 8
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

Joined: Feb 20, 2001
Posts: 3695

activation.jar as well?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: No classdef found error