JavaMail Problem

Discussion in 'Java' started by AC, Jan 20, 2005.

  1. AC

    AC Guest

    I'm a beginner to programming in Java (I'm switching over from VB because
    I'm in a company that is beginning the transition from MS environments and I
    need to start porting software to a platform that can run on Linux and
    Windows machines). I'm telling you this so you'll be kind :)

    Anyways, I'm using the NetBeans 4.0 IDE and have a small application that
    downloads some data from one of our internal web sites, massages the data
    and sends it out via email. I've managed to get to the email point, and
    downloaded the JAF and JavaMail APIs, sticking mail.jar and activation.jar
    into the jre/lib/ext directory (I'm actually doing the the development on a
    Windows box). I can run my application without a hitch in NetBeans, but
    when I try to run the jar file straight from the command prompt I get the
    following error:

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

    I don't have any of the jar files set in the NetBeans project itself, so I'm
    assuming I don't need to muck around with class paths because it is in the
    jre/lib/ext. Is there something I'm missing?

    --
    Aaron Clausen
    AC, Jan 20, 2005
    #1
    1. Advertising

  2. AC

    dar7yl Guest

    You are missing the manifest in the jar file. See the section "Packaging
    Your Application in a JAR File" in
    http://java.sun.com/j2se/1.4.2/runtime.html .

    regards,
    Dar7yl

    "AC" <> wrote in message
    news:...
    > I'm a beginner to programming in Java (I'm switching over from VB because
    > I'm in a company that is beginning the transition from MS environments and
    > I
    > need to start porting software to a platform that can run on Linux and
    > Windows machines). I'm telling you this so you'll be kind :)
    >
    > Anyways, I'm using the NetBeans 4.0 IDE and have a small application that
    > downloads some data from one of our internal web sites, massages the data
    > and sends it out via email. I've managed to get to the email point, and
    > downloaded the JAF and JavaMail APIs, sticking mail.jar and activation.jar
    > into the jre/lib/ext directory (I'm actually doing the the development on
    > a
    > Windows box). I can run my application without a hitch in NetBeans, but
    > when I try to run the jar file straight from the command prompt I get the
    > following error:
    >
    > Exception in thread "main" java.lang.NoClassDefFoundError:
    > javax/mail/Message
    >
    > I don't have any of the jar files set in the NetBeans project itself, so
    > I'm
    > assuming I don't need to muck around with class paths because it is in the
    > jre/lib/ext. Is there something I'm missing?
    >
    > --
    > Aaron Clausen
    >
    dar7yl, Jan 20, 2005
    #2
    1. Advertising

  3. AC

    AC Guest

    On Thu, 20 Jan 2005 19:04:49 GMT,
    dar7yl <> wrote:
    > You are missing the manifest in the jar file. See the section "Packaging
    > Your Application in a JAR File" in
    > http://java.sun.com/j2se/1.4.2/runtime.html .


    Well, I'm using NetBeans to build the jar file, and from what I can tell
    this is the manifest file:

    Manifest-Version: 1.0
    X-COMMENT: Main-Class will be added automatically by build

    I'm just going to a shell and running the NetBeans-built jar file manually.
    LIke I said though, I'm a beginner, so I'm sure I'm missing something
    terribly obvious (though from a google search it looks like JavaMail can be
    a pain in the a**).

    --
    Aaron Clausen
    AC, Jan 20, 2005
    #3
  4. AC

    dar7yl Guest

    "AC" <> wrote in message
    news:...
    >...though from a google search it looks like JavaMail can be
    > a pain in the a*


    JavaMail is intimidating at first, but once you set it up, you'll find it's
    actually quite easy to use (for basic operations).

    BTW, you can use your ISP's mail server, so you don't have to grow your own.

    regards,
    Dar7yl
    dar7yl, Jan 20, 2005
    #4
  5. AC

    AC Guest

    On Thu, 20 Jan 2005 22:02:40 GMT,
    dar7yl <> wrote:
    >
    > "AC" <> wrote in message
    > news:...
    >>...though from a google search it looks like JavaMail can be
    >> a pain in the a*

    >
    > JavaMail is intimidating at first, but once you set it up, you'll find it's
    > actually quite easy to use (for basic operations).
    >
    > BTW, you can use your ISP's mail server, so you don't have to grow your own.


    Well, I've got it sending mail through our mail server just fine within the
    NetBeans environment. I just can't get it to do it from "java -jar", even
    though both the activation.jar and mail.jar files are in the jre/lib/ext
    directory. Do I actually have to add this directory to the class path?

    --
    Aaron Clausen
    AC, Jan 20, 2005
    #5
  6. AC

    dar7yl Guest

    Re: JavaMail Problem, Application Environments

    "AC" <> wrote in message
    news:...
    >
    > Well, I've got it sending mail through our mail server just fine within
    > the
    > NetBeans environment. I just can't get it to do it from "java -jar", even
    > though both the activation.jar and mail.jar files are in the jre/lib/ext
    > directory. Do I actually have to add this directory to the class path?


    You shouldn't have to, but then again, you never can tell what's happening
    in your environment. What sort of errors are you getting? Show stack
    traces.

    That's why I dislike the beans environment. It isolates you too much from
    the actual real-world situations you are likely to encounter, such as
    configuration issues, communication problems, security, and downright user
    hostility.

    When you are running at the applications level (that is, starting a .jar
    from the command line), you have to make sure your environment is as
    self-contained as possible. Also you may have to adjust your security
    settings. Make sure you have an appropriate .policy file (either local or
    in $JAVA_BASE/lib/security/java.policy). Don't forget to put the start
    class into the manifest.

    Running as an applet means that you have to provide all those excess
    libraries to the client's computer (as .jars in html applet archive
    parameter or by direct install), as well as provide some sort of mail server
    or relay because the client can only open sockets back to your internet
    address, without having to be c.ertificated.

    Finally, running as a server means that you have a whole lot of
    configuration issues to deal with. Much steep learning curve. Many
    packages to install. Many manuals to read. Good cure for insomnia.

    regards,
    Dar7yl
    dar7yl, Jan 20, 2005
    #6
  7. AC sez:
    > On Thu, 20 Jan 2005 19:04:49 GMT,
    > dar7yl <> wrote:
    >> You are missing the manifest in the jar file. See the section "Packaging
    >> Your Application in a JAR File" in
    >> http://java.sun.com/j2se/1.4.2/runtime.html .

    >
    > Well, I'm using NetBeans to build the jar file, and from what I can tell
    > this is the manifest file:
    >
    > Manifest-Version: 1.0
    > X-COMMENT: Main-Class will be added automatically by build
    >
    > I'm just going to a shell and running the NetBeans-built jar file manually.
    > LIke I said though, I'm a beginner, so I'm sure I'm missing something
    > terribly obvious (though from a google search it looks like JavaMail can be
    > a pain in the a**).


    java -verbose:class is your friend. It'll show you exactly what classes
    it's loading and where from.

    Dima
    --
    The wombat is a mixture of chalk and clay used for respiration. -- MegaHal
    Dimitri Maziuk, Jan 21, 2005
    #7
  8. AC

    AC Guest

    On Fri, 21 Jan 2005 01:58:20 +0000 (UTC),
    Dimitri Maziuk <dima@127.0.0.1> wrote:
    > AC sez:
    >> On Thu, 20 Jan 2005 19:04:49 GMT,
    >> dar7yl <> wrote:
    >>> You are missing the manifest in the jar file. See the section "Packaging
    >>> Your Application in a JAR File" in
    >>> http://java.sun.com/j2se/1.4.2/runtime.html .

    >>
    >> Well, I'm using NetBeans to build the jar file, and from what I can tell
    >> this is the manifest file:
    >>
    >> Manifest-Version: 1.0
    >> X-COMMENT: Main-Class will be added automatically by build
    >>
    >> I'm just going to a shell and running the NetBeans-built jar file manually.
    >> LIke I said though, I'm a beginner, so I'm sure I'm missing something
    >> terribly obvious (though from a google search it looks like JavaMail can be
    >> a pain in the a**).

    >
    > java -verbose:class is your friend. It'll show you exactly what classes
    > it's loading and where from.


    I think I found my problem. Apparently there is another copy of the JRE on
    the machine I'm working on.

    --
    Aaron Clausen
    AC, Jan 21, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news
    Replies:
    0
    Views:
    332
  2. Jason

    q javamail compile problem

    Jason, Dec 15, 2003, in forum: Java
    Replies:
    3
    Views:
    391
    Jason
    Dec 19, 2003
  3. Nilambari

    problem sending javamail

    Nilambari, Dec 23, 2003, in forum: Java
    Replies:
    2
    Views:
    8,305
    Ulas Ergin
    Dec 26, 2003
  4. mrby

    Problem about JavaMail

    mrby, Apr 29, 2004, in forum: Java
    Replies:
    1
    Views:
    458
    GaryM
    Apr 29, 2004
  5. Bobby Martin

    JavaMail sending problem and solution

    Bobby Martin, May 19, 2004, in forum: Java
    Replies:
    4
    Views:
    5,729
    Bobby Martin
    May 21, 2004
Loading...

Share This Page