Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9029343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:13:44+00:00 2026-06-16T07:13:44+00:00

I wrote a small Java command line program to test sending emails from a

  • 0

I wrote a small Java command line program to test sending emails from a remote server. I’m getting the dreaded “NoClassDefFoundError” and I can’t figure out why.

The server is running:

  • SunOS 5.10 Generic January 2005
  • Java 1.5.0_30-b03 ( Sun, standard )

My java program is called

SendEmailACME

The error message is

Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource

The complete output from the run of the program is:

bash-3.00$ javac SendEmailACME.java
bash-3.00$ java SendEmailACME
SendEmailACME: Classpath: .:/users/steve/TestProgramsLib/mail.jar:users/steve/TestProgramsLib/activation.jar
DEBUG: setDebug: JavaMail version 1.4.4
Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource
        at SendEmailACME.main(SendEmailACME.java:47)
bash-3.00$ 

I ran

java -verbose SendEmailACME

The ouput was too long for stackoverflow. All it included was the regular output, plus a bunch of messages about java loading all of its regular libraries, the libraries from mail.jar, but I didn’t see any from javax.activation.*

Output from “$ echo $CLASSPATH” is:

bash-3.00$ echo $CLASSPATH
.:/users/steve/TestProgramsLib/mail.jar:users/steve/TestProgramsLib/activation.jar
bash-3.00$

My home directory is

/users/steve

It contains these two directories

  1. TestPrograms
  2. TestProgramsLib

The first has my program SendEmailACME.java, SendEmailACME.class/
The second has the following jars in it:

bash-3.00$ ls -l
total 1102
-rw-r--r--   1 steve  acme      55932 Apr 19  2006 activation.jar
-rw-r--r--   1 steve  acme     494975 Jan 14  2011 mail.jar
bash-3.00$

This is the source code of my command line program SendEmailACME:

import javax.mail.*;
import javax.mail.internet.*;
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;

import java.util.Properties;

public class SendEmailACME {


    public static void main(String[] args) throws Exception{


        String smtpServer  = "msg.abc.acme.com";
        int port           = 25;        
        String userid      = "acme.staffdirectory"; 
        String password    = "password";  
        String contentType = "text/html";

        String subject     = "test: Send An Email, From A Java Client Using msg.abc.acme.com";
        String from        = "ACME.Staff.Directory@acme.com";
        String to          = "steve@acme.com,joerre123@gmail.com,fake.mail@acme.com,bogus@fauxmail.com";
        String body        = "<h1>Test. An Email, From A Java Client Using msg.abc.acme.com.</hi>";

        System.out.println("SendEmailACME: Classpath: " + System.getProperty("java.class.path"));

        Properties props   = new Properties();
        props.put("mail.transport.protocol", "smtp");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.starttls.enable","true");
        props.put("mail.smtp.host", smtpServer);

        Session mailSession = Session.getInstance(props);

        // Get runtime more runtime output when attempting to send an email
        mailSession.setDebug(true);

        MimeMessage message = new MimeMessage(mailSession);
        message.setFrom(new InternetAddress(from));
        message.setRecipients(Message.RecipientType.TO, to);
        message.setSubject(subject);
        message.setContent(body,contentType);

        Transport transport = mailSession.getTransport();
        transport.connect(smtpServer, port, userid, password);
        transport.sendMessage(message,message.getRecipients(Message.RecipientType.TO));
        transport.close();
    }// end function main()

}// end class SendEmailACME

Here is the output from running a command to see what is inside activation.jar:

bash-3.00$ jar -tf activation.jar
META-INF/MANIFEST.MF
META-INF/SUN_MICR.SF
META-INF/SUN_MICR.RSA
META-INF/
META-INF/mailcap.default
META-INF/mimetypes.default
javax/
javax/activation/
javax/activation/ActivationDataFlavor.class
javax/activation/MimeType.class
javax/activation/MimeTypeParameterList.class
javax/activation/MimeTypeParseException.class
javax/activation/CommandInfo.class
javax/activation/DataHandler$1.class
javax/activation/DataHandler.class
javax/activation/DataSource.class
javax/activation/CommandMap.class
javax/activation/DataContentHandler.class
javax/activation/DataContentHandlerFactory.class
javax/activation/CommandObject.class
javax/activation/DataHandlerDataSource.class
javax/activation/DataSourceDataContentHandler.class
javax/activation/ObjectDataContentHandler.class
javax/activation/FileDataSource.class
javax/activation/FileTypeMap.class
javax/activation/MailcapCommandMap.class
javax/activation/MimetypesFileTypeMap.class
javax/activation/SecuritySupport$1.class
javax/activation/SecuritySupport$2.class
javax/activation/SecuritySupport$3.class
javax/activation/SecuritySupport$4.class
javax/activation/SecuritySupport$5.class
javax/activation/SecuritySupport.class
javax/activation/URLDataSource.class
javax/activation/UnsupportedDataTypeException.class
com/
com/sun/
com/sun/activation/
com/sun/activation/registries/
com/sun/activation/registries/MailcapFile.class
com/sun/activation/registries/MailcapParseException.class
com/sun/activation/registries/MimeTypeFile.class
com/sun/activation/registries/MimeTypeEntry.class
com/sun/activation/registries/LineTokenizer.class
com/sun/activation/registries/LogSupport.class
com/sun/activation/registries/MailcapTokenizer.class
com/sun/activation/viewers/
com/sun/activation/viewers/ImageViewer.class
com/sun/activation/viewers/ImageViewerCanvas.class
com/sun/activation/viewers/TextEditor.class
com/sun/activation/viewers/TextViewer.class
bash-3.00$

Everything compiles fine, but it can’t seem to find javax.activation.DataSource despite activation.jar being in the classpath

I do not have access to the jdk_home/jre/lib/ext directory.

I have been attempting to execute SendEmailACME from my directory
/users/steve/TestPrograms

Thanks in advance for any help

Steve

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:13:45+00:00Added an answer on June 16, 2026 at 7:13 am
    bash-3.00$ echo $CLASSPATH
    .:/users/steve/TestProgramsLib/mail.jar:users/steve/TestProgramsLib/activation.jar
    

    You appear to be missing a / between mail.jar: and users/steve. This means java is looking in the wrong place for activation.jar (in ./users rather than /users).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a small email sending program in java, it has from , to
I wrote two small applications (a client and a server) to test UDP communication
I wrote a small test program for flipperview. I have 3 views. I call
I wrote a small program in Java that do divide operation on pair of
I wrote a small java program in Netbeans. It compiles and runs perfectly. But
I recently inherited a small Java program that takes information from a large database,
I wrote a small HTTP server in Java and I have a problem passing
I wrote two small java programs: a TCP client which sends many lines of
I am getting ready to write lot of small experimental java programs as I
I am trying to write a small application using bouncycastle algorithm, from the BouncyCastleProvider.java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.