• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

No classdef found error

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");
}
}
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
activation.jar as well?
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic