?
Solved

Problems with running compiled code

Posted on 2005-03-07
2
Medium Priority
?
864 Views
Last Modified: 2013-11-23
Hello there,
I have an MTA application called power mta which has a java api to send email into it. I have placed the jar file provided into the jre/lib/ext directory and the example code compiled without a problem. However, when I run the app I get the following error:

C:\Documents and Settings\Administrator\Desktop\MPFeeder\examples>java ExampleMe
ssage
Exception in thread "main" java.lang.NoClassDefFoundError: com/port25/pmta/api/s
ubmitter/EmailAddressException

What does this error mean? I have called them about this and they say they cant duplicate the error. Here is the ExampleMessage.java code:

import java.io.IOException;
import com.port25.pmta.api.submitter.*;

/*
 * Example for usage of the Java PMTA Submitter API.
 *
 * Copyright 2002 by Port25 Solutions, Inc.
 * All rights reserved.
 *
 * Don't forget to set the LD_LIBRARY_PATH environment variable to include
 * the directory where libpmtajava.so (or pmtajava.dll) is in, e.g. on
 * Linux and with bash use
 *      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
 * if it is not in the default library path.
 *
 * $Id: ExampleMessage.java,v 1.15 2004/06/02 14:24:43 robert Exp $
 *
 */
public class ExampleMessage {
    public static void main(String args[]) {
        String text =
            "Subject: Sent using the PMTA Java API\n" +
            "To: To You <rick@infotech.com>\n" +
            "From: From Me <rick@infotech.com>\n" +
            "\n" +
            "This message was sent via PowerMTA's native Java API.\n";
        Message msg = new Message("rick@infotech.com");
        try {
            Recipient rcpt = new Recipient("rick@infotech.com");
            msg.addRecipient(rcpt);
            msg.setReturnType(Message.RETURN_FULL);
            msg.addDateHeader();
            msg.setEncoding(Message.ENCODING_8BIT);
            msg.addData(text.getBytes());
            Connection conn = new Connection("local:");
            conn.submit(msg);
        }
        catch (ServiceException se) {
            se.printStackTrace();
        }
        catch (EmailAddressException eae) {
            eae.printStackTrace();
        }
        catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}


Can someone please tell me what I am doing wrong? The correct fix is worth 500 points.

Thanks,
Rick
0
Comment
Question by:richardsimnett
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 13482743
The compiler uses a different VM than when you run your app.
So you need to also place the jar in your JRE's ext directory.
The JRE is probably installed under Program Files.
0
 

Author Comment

by:richardsimnett
ID: 13482903
Objects,
Well that worked. Thanks a million.

Cheers,
Rick
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question