0

Already there are too many questions with this. Possible duplicate:
1. How to open an email client and automatically attach file in java
2. Start Mail-Client with Attachment?

My requirement is: 1. open default email client from Java.
2. add 'to' address, Subject and body text from Java.
3. Attach a file to the mail

However these two are not working for me...
JDIC:
When I use JDIC I am getting the following error:
java.lang.ClassNotFoundException: org.jdesktop.jdic.desktop.internal.impl.ServiceManagerStub_unix

JMAPI:
When I use JMAPI I am getting following.

java.lang.UnsatisfiedLinkError: org.jdesktop.jdic.desktop.internal.impl.WinAPIWrapper.RegOpenKey(I[BI)[I
    at org.jdesktop.jdic.desktop.internal.impl.WinAPIWrapper.RegOpenKey(Native Method)
    at org.jdesktop.jdic.desktop.internal.impl.WinAPIWrapper.WinRegQueryValueEx(WinAPIWrapper.java:170)
    at jmapi.JMAPI.isMapiSupported(JMAPI.java:40)
    at com.turborep.turbotracker.mail.SendQuoteMail.send(SendQuoteMail.java:120)
    at com.turborep.turbotracker.mail.SendEmail.main(SendEmail.java:77)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:212)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

I assume, JMAPI will work only with windows machines (because need to open jdic.dll library).
My machine is: Ubuntu 12.04 & JDK6

Is there any other possibility to achieve this in Ubuntu.

Thanks in advance.

**EDIT: ** My machine is running with 64 bit JVM.

Community
  • 1
  • 1
vissu
  • 1,921
  • 7
  • 37
  • 52

1 Answers1

2

you (or some library you include) are using the JDesktop Integration Components (JDIC) project, which has a version per target operating system and requires native libraries (which it uses via JNI).

your 1st error

java.lang.ClassNotFoundException: org.jdesktop.jdic.desktop.internal.impl.ServiceManagerStub_unix

is probably caused by deplying the windows (or any non-unix) version of the library on a unix machine.

while your 2nd error

java.lang.UnsatisfiedLinkError: org.jdesktop.jdic.desktop.internal.impl.WinAPIWrapper.RegOpenKey(I[BI)[I
    at org.jdesktop.jdic.desktop.internal.impl.WinAPIWrapper.RegOpenKey(Native Method)

means that either youre not including the requires dll properly or that you're running on a 64-bit JVM using a 32-bit dll - see more info here (this is someone with your exact issue)

radai
  • 23,949
  • 10
  • 71
  • 115
  • Thanks for your instant and valuable reply. on **2nd**, Yes My JVM is 64 bit. is it not possible to use 32 bit dll in my case? Then please guide me to the right direction. (Because JMAPI is using 32 bit jdic.dll). – vissu Jan 11 '13 at 06:36
  • @vissu - the quickest solution would be to use a 32-bit jvm (those run just fine on 64-bit windows) - unless you cant fit into ~1.5GB heap. unfortunately i couldnt find any binaries of the library, just the source (http://java.net/projects/jdic/sources/svn/show) but if you have the time and resources you could probably compile a 64-bit version of it. – radai Jan 11 '13 at 06:47
  • Thank you very much. I will try to compile the source for 64 bit. – vissu Jan 11 '13 at 07:38
  • Hai @radai, can we achive this through any applet? Which will ask client user permission to run and open the email client. Please suggest me. – vissu Jan 23 '13 at 08:16
  • @vissu - for ways of opening the system default email client see this - http://stackoverflow.com/questions/17373/how-do-i-open-the-default-mail-program-with-a-subject-and-body-in-a-cross-platfo – radai Jan 23 '13 at 18:17