dcsimg
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   bob_burns
Posted On:   Thursday, June 3, 2004 06:20 AM

Hi I just installed java's sdk 1.4.2_04 and had a few problems getting the hello world sample to work even though I had set the Path variable correctly, got some advice that mentioned I should include the -cp switch before running sample and it did work. But I have downloaded Java's Mail API and the Jaf package required to enable the Mail API to work. I set the ClassPath correctly as the instruction guide instructed but when i tried running a test application it compiled correctly but did run, instead returned the following error . Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException. Here is the cod   More>>

Hi

I just installed java's sdk 1.4.2_04 and had a few problems
getting the hello world sample to work even though I had
set the Path variable correctly, got some advice that
mentioned I should include the -cp switch before running
sample and it did work. But I have downloaded Java's Mail
API and the Jaf package required to
enable the Mail API to work. I set the ClassPath correctly as the instruction
guide instructed but when i tried running a test
application it compiled correctly but did run, instead
returned the following error
.
Exception in thread "main" java.lang.NoClassDefFoundError:
javax/mail/MessagingException.

Here is the code I was running

import javax.mail.*;

import java.util.Properties;

import javax.mail.internet.*;


public class Test {


public static void main(String[] args)

{

Properties props = new Properties();

//set mail server

props.put("mail.stmp.host","localhostgoeshere");

//create sessionv
Session session = Session.getDefaultInstance(props,null);

//error throwing code

try

{

System.out.println("Create Mime");

MimeMessage message = new MimeMessage(session);

//fill in addressing info

message.setFrom(new InternetAddress("bob_burns@mail.com"));

System.out.println("Set From");

message.addRecipient(Message.RecipientType.TO,new InternetAddress("bob_burns@mail.com"));

message.setSubject("Testing Mail Merge");

message.setText("It works! Hello World");

//send message

System.out.println("Sending Mesage");

// Transport.send(message);

System.out.println("Message Sent!!");

}//end of try

catch(AddressException ae)

{

ae.printStackTrace();

}

catch(MessagingException me)

{

me.printStackTrace();

}//end of catch
}//end of main

}//end of class

Please help!

   <<Less

Re: Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException

Posted By:   Jean_Hernandez  
Posted On:   Friday, July 2, 2004 08:48 AM

Hi bob burns, your problem is in the execution of your code.



javac -cp %CLASSPATH% Test.java

java -cp . Test



Is the solution of the message Exception in thread "main"
java.lang.NoClassDefFoundError: ...



Is you have other question about this problem please let me
know.



Thank, Saludos.

Re: Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException

Posted By:   Sean_Owen  
Posted On:   Thursday, June 3, 2004 07:16 AM

Your run-time classpath still doesn't include the javax.mail.MessagingException class, so I bet you don't have mail.jar in the classpath. You'll have to double-check your classpath settings. Typically, either you set your classpath in a "CLASSPATH" variable, or you pass them to java's -cp flag.
About | Sitemap | Contact