簡體   English   中英

ClassNotFoundException:org.eclipse.swt.widgets.Display

[英]ClassNotFoundException: org.eclipse.swt.widgets.Display

我需要使用按鈕創建一個jsp頁面-單擊該按鈕時,它將在Outlook中打開“新建”電子郵件窗口,並在其中填充“收件人”,“主題”和“正文”字段。

我是通過servlet實現的,因此當用戶單擊按鈕時,將調用servlet,並從servlet類的doGet()中調用以下代碼。

當我嘗試將其作為獨立的Java應用程序進行測試時,此方法效果很好,並且新的消息窗口完美打開。 但是,當我嘗試通過jsp表單打開它時,出現了異常。

例外情況:

java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Display

我包括以下罐子:

org.eclipse.swt.win32.win32.x86_3.7.0.v3735b.jar
org.eclipse.core.commands_3.6.0.I20110111-0800.jar

來自以下網址的代碼: http : //www.vogella.com/tutorials/EclipseMicrosoftIntegration/article.html

代碼:

Display display = Display.getCurrent();
Shell shell = new Shell(display);
OleFrame frame = new OleFrame(shell, SWT.NONE);
// This should start outlook if it is not running yet
OleClientSite site = new OleClientSite(frame, SWT.NONE, "OVCtl.OVCtl");
site.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
// now get the outlook application
OleClientSite site2 = new OleClientSite(frame, SWT.NONE,"Outlook.Application");
OleAutomation outlook = new OleAutomation(site2);
OleAutomation mail = invoke(outlook, "CreateItem", 0 /* Mail item */)
        .getAutomation();
setProperty(mail, "To", "someone@something.com"); /*
                           * Empty but could also be
                           * predefined
                           */
// setProperty(mail, "Bcc", "test@gmail.com"); 
/*
                           * Empty but could also be
                           * predefined
                           */
setProperty(mail, "BodyFormat", 2 /* HTML */);
setProperty(mail, "Subject", "Top News for you");
        setProperty(mail, "HtmlBody",
            "some message");
//      File file = new File("c:/temp/test.txt");
//      if (file.exists()) {
//        OleAutomation attachments = getProperty(mail, "Attachments");
//        invoke(attachments, "Add", "c:/temp/test.txt");
//      } else {
//        MessageDialog
//            .openInformation(shell, "Info",
//                "Attachment File c:/temp/test.txt not found; will send email with attachment");
//      }
invoke(mail, "Display" /* or "Send" */);

在Java的Web應用程序中使用jar時,已將jar文件放在項目的lib文件夾中。 因此,請確保您這樣做。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM