You are currently viewing the BOOK: Beginning Cryptography with Java section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
The bcmail and bcprov jars were already added to lib\ext so I removed them from the command line - but problem still not solved...
I added code (at the beginning of main()) to construct an instance of javax.mail.MessagingException and then print out the class name and message. No exceptions are encountered until the line where the generator is constructed.
Actually this will make the problem worse - you have a different class loader loading the BC mail API from the java mail API and the first class loader won't talk to the second one. Try adding the javamail and activation jars to lib/ext as well.
It all works from the command line now, but when I run under Eclipse I get the following exception:
Exception in thread "main" java.security.NoSuchProviderException: JCE cannot authenticate the provider BC
at org.bouncycastle.mail.smime.SMIMEEnvelopedGenerato r.make(Unknown Source)
at org.bouncycastle.mail.smime.SMIMEEnvelopedGenerato r.generate(Unknown Source)
at chapter9.EnvelopedMailExample.main(EnvelopedMailEx ample.java:57)
Caused by: java.util.jar.JarException: Class is on the bootclasspath
... 5 more
Why would the provider be authenticated from command line, but not from within Eclipse?
I have bcmail and bcprov and mail and activation jars in JDK\jre\lib\ext
I have the following line added to the java.security file of JDK\jre :
I have made sure that the JRE system library in Eclipse includes the bcmail, bcprov, mail and activation jars.
I also have the unrestricted policy jars copied to my JDK\jre\lib\security directory.
Hi. I have a similar problem. I am using NetBeans 4.0 with JDK 1.5.0_06. I have an application that sends messages using Javamail. It works fine with the IDE but when I want to run the .jar from command line I get
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException
I have copied mail.jar and activation.jar in jre/lib/ext and /lib.
1. How can I specify the classpath using the the -jar option (Since I want to run a jar, not a class)?
2. How would I modify the manifest to "tell" the jar where to look?
You can find details on 1 and 2 in the documentation for the java tool and the documentation on jar files that comes with the JDK.
With the missing class, the most common reason for this, if you're using windows, is that the command line uses the JRE install not the JDK install. If you are using windows you should check that lib/ext of the JRE install also contains the jar file.
The other reason this can happen is if the jar has somehow being included twice in the classpath.