Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with sending JavaMail via command line  RSS feed

 
Mike London
Ranch Hand
Posts: 1332
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a simple Java class that sends an email when run. It works fine when run from within the IDE.

However, when I try to run the same code from the command line, I get this error stack:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/internet/AddressException
Caused by: java.lang.ClassNotFoundException: javax.mail.internet.AddressException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

(Huh?)

The AddressException is fully referenced in the catch clause and no errors (missing imports) are noted. (Again, this code runs perfectly when run from within the IDE.)

Any ideas why the same code that works fine from the IDE does not work when run from the command line?

Thanks in advance for any help or suggestions.

mike
 
Mike London
Ranch Hand
Posts: 1332
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fixed it.

When running from the command line, I needed to add the javamail jar directory to the -classpath option of the java command line.

Works great now.

mike
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!