views:

50

answers:

1

I have a javamail app that works fine in the Android/Eclipse environment, but throws the following in NetBeans (porting Android app to Desktop):

javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed boundary="----=_Part_0_7749469.1284737984291"

I found a workaround here, but can't figure out how to apply it in NetBeans. I have already added mail.jar to my NetBeans compile time libraries but don't understand how to set the NetBeans boot class path to include mail.jar as suggested in the workaround. From http://www.opensubscriber.com/message/[email protected]/7570201.html

JAF uses the context class loader to load classes. If that fails, it uses the class loader that loaded the JAF classes.

When JAF is packaged with the application, the JAF classes are loaded by the same class loader as the other application classes, so even if the context class loader isn't set JAF can find the other application classes.

When JAF is part of the JDK, the JAF classes are loaded by the system class loader. Without the context class loader being set, JAF has no way to find the appropriate class loader to load application classes.

(Since JavaMail is packaged with the application, the JavaMail class are treated the same as application classes.)

A workaround is to set the boot class path to include mail.jar.

How do I set the NetBeans boot class path to include mail.jar?

+1  A: 

Unless you're writing a NB plugin, you don't want it on the NB boot class path. You want it on your project's class path.

First you need to add mail.jar as a library.

  • Tools > Libraries
  • New Library
  • Library name Java Mail
  • Library Type: Class Libraries
  • OK
  • Add JAR/Folder
  • Browse to the javamail.jar
  • Add JAR/Folder
  • OK

Now, add the library to your project

  • File > Project Properties
  • Libraries
  • Compile tab
  • Add Library
  • (If you're using NB 6.9, there may be an additional Import Libraries step here)
  • Select Java Mail from the list
  • OK

That should be it.

Note that you will needs to ensure the javamail.jar is distributed with your application; either directly or through a jnlp file.

Devon_C_Miller
Sorry. Didn't help. As I said in the original question, I have already added mail.jar to my NetBeans compile time libraries (along with activation.jar and additional.jar), but there seems to be some issue with the context class loader as discussed here: http://www.opensubscriber.com/message/[email protected]/7570201.html. I attempted your procedure (I had used a slightly different method earlier) but that only appeared to add the libraries again. The workaround suggested above is to set the boot class path to include mail.jar, but again, I have no idea how to do that.
JackN
I got rid of the error by removing activation.jar. According to http://www.oracle.com/technetwork/java/index-138643.html `Unless you're using Java SE 6, you will also need the JavaBeans Activation Framework (JAF) extension that provides the javax.activation package. We suggest you use version 1.1.1 of JAF, the latest release. JAF is included with Java SE 6.` Your procedure is correct. I needed activation.jar (and additional.jar) in my android environment. Thanks.
JackN