Results 1 to 11 of 11
  1. #1
    lse123 is offline Senior Member
    Join Date
    Oct 2008
    Posts
    116
    Rep Power
    0

    Default simple send email APP, but when press send button appeared:

    I run
    java -jar SMTPClient.jar // run from CLI
    simple send email APP[GUI], but when press send button appeared:
    Java Code:
      C:\Users\User\Documents\TextBooksDataFiles\Java Network Programming, 3rd Edition\jnp3examples\examples\19>java -jar SMTPClient.jar
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: SMTPClient$SendAction$1
            at SMTPClient$SendAction.actionPerformed(SMTPClient.java:270)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
            at java.awt.Component.processMouseEvent(Component.java:6263)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
            at java.awt.Component.processEvent(Component.java:6028)
            at java.awt.Container.processEvent(Container.java:2041)
            at java.awt.Component.dispatchEventImpl(Component.java:4630)
            at java.awt.Container.dispatchEventImpl(Container.java:2099)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
            at java.awt.Container.dispatchEventImpl(Container.java:2085)
            at java.awt.Window.dispatchEventImpl(Window.java:2475)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Caused by: java.lang.ClassNotFoundException: SMTPClient$SendAction$1
            at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
            ... 26 more

  2. #2
    HerrK. is offline Member
    Join Date
    Jun 2010
    Location
    Berlin
    Posts
    22
    Rep Power
    0

    Default

    Well, it would be quite nice to get some more information. Of course anyone who wants to help you could search for this .jar file and maybe someone will guess that it is related to some O'Reilly book, but this could (way easier) be mentioned by you.

    While I don't have this book (and therefore no access to the .jar file), I can't really help you without further infos. I found some example code that I could download, but the archive contains only .java files. So have you created the package by yourself?

    The exception that is thrown is allready telling you what's going on. You trigger some event that refers to some function of the SMTPClient class, which is not known. This might be caused by some missing library. Just try to unpack the .jar file (if it doesn't work directly rename it to a .zip archive). You will find some folder META-INF which should contain the manifest.MF file. This file should contain some information, like the class to run as the main. Is there some line starting by "Class-Path:"? If so, you have to ensure that these files or (relative) pathes are accessible.

    Best regards,
    Herr K.

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,790
    Rep Power
    25

    Default

    Where did you get the jar file? It appears to be missing a class definition file.

  4. #4
    lse123 is offline Senior Member
    Join Date
    Oct 2008
    Posts
    116
    Rep Power
    0

    Default

    Manifest-Version: 1.0
    Class-Path: lib/mail.jar
    Created-By: 1.6.0_15 (Sun Microsystems Inc.)
    Main-Class: SMTPClient

    this reads is it correct? book [ch 19 / file name same] oreilly:
    Java Network Programming, 3rd Edition
    but modified code myself.

    may zip file/folders and attach it to try it you?


    in shortcut
    target:"C:\Users\User\Documents\TextBooksDataFiles \Java Network Programming, 3rd Edition\jnp3examples\examples\19\SMTPClient.jar"
    startin:"C:\Users\User\Documents\TextBooksDataFile s\Java Network Programming, 3rd Edition\jnp3examples\examples\19"
    the jar is in the
    C:\Users\User\Documents\TextBooksDataFiles\Java Network Programming, 3rd Edition\jnp3examples\examples\19\lib\mail.jar

    only from running [CLI] the- java SMTPClient .class -email delivered

  5. #5
    lse123 is offline Senior Member
    Join Date
    Oct 2008
    Posts
    116
    Rep Power
    0

    Default I attach without mail.jar in .../lib/ , well?

    I attach without mail.jar in .../lib/ , well?
    Attached Files Attached Files

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,790
    Rep Power
    25

    Default

    Yes, the manifest looks ok. Without the correct Main-Class: line, the JVM wouldn't be able to start the program.
    When you look in the jar file, do you see the file: SMTPClient$SendAction$1.class

    modified code myself
    Did you create an anonymous class in SendAction?

    Just downloaded your zip file. I searched the .jar file with a tool I have and got this report:
    #Searching C:\Documents and Settings\Owner\My Documents\Downloads\SMTPClient\SMTPClient.jar for SMTPClient
    SMTPClient
    SMTPClient$1
    SMTPClient
    SMTPClient$2
    SMTPClient
    SMTPClient$3
    SMTPClient
    SMTPClient$4
    SMTPClient
    SMTPClient$SendAction
    SMTPClient
    SMTPClient$SendAction$1 >>>> class NOT found! <<<<
    SMTPClient$UpdateListener
    SMTPClient

    # Found 8 classes. 1 NOT found.
    How are you generating the .jar file? You need to add the missing class
    Last edited by Norm; 06-06-2010 at 05:03 PM.

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by lse123 View Post
    I run
    java -jar SMTPClient.jar // run from CLI
    simple send email APP[GUI], but when press send button appeared:
    Java Code:
      C:\Users\User\Documents\TextBooksDataFiles\Java Network Programming, 3rd Edition\jnp3examples\examples\19&gt;java -jar SMTPClient.jar
    Exception in thread &quot;AWT-EventQueue-0&quot; java.lang.NoClassDefFoundError: SMTPClient$SendAction$1
    Your SMTPClient class has a nested class named SendAction which has an anonymous inner class (I guess it's an implementation of the ActionListener interface, but that's just a guess). That class is not stored in your .jar file.

    kind regards,

    Jos

  8. #8
    lse123 is offline Senior Member
    Join Date
    Oct 2008
    Posts
    116
    Rep Power
    0

    Default

    I added SMTPClient$SendAction$1 and now works, thks!

    in the above class name "$" show inner classes? may included in any order in->...?

    jar cmf SMTPClient.mf SMTPClient.jar SMTPClient.class SMTPClient$SendAction.class SMTPClient$SendAction$1.class SMTPClient$UpdateListener.class SMTPClient$1.class SMTPClient$2.class SMTPClient$3.class SMTPClient$4.class SMTPClient.java

  9. #9
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,790
    Rep Power
    25

    Default

    You can use a wild card (*) in the jar statement: SMTPClient*.class vs the explicit list which can change if you add another anonymous class.

  10. #10
    lse123 is offline Senior Member
    Join Date
    Oct 2008
    Posts
    116
    Rep Power
    0

    Default

    What you mean "which can change if you add another anonymous class. ", are you mean use same statement to recreate jar, in case modify file.java?

  11. #11
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,790
    Rep Power
    25

    Default

    The compile names the anonymous classes it generates. It's possible for it to create one that is not listed in the list of class files you are loading into the jar file. If you use a wild card char to select the files to add, you will pickup all classes, not missing any.

Similar Threads

  1. how to send an email
    By Hussain Ali in forum Advanced Java
    Replies: 9
    Last Post: 03-19-2010, 08:44 AM
  2. how to send an email
    By painamrata in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 02-22-2009, 05:28 PM
  3. send email using JMS
    By Heather in forum Advanced Java
    Replies: 9
    Last Post: 01-07-2009, 04:04 PM
  4. send email using apache commons email
    By jnamendi in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 10-14-2008, 06:55 PM
  5. Email send problem
    By serjant in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 09-19-2008, 03:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •