gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 13:15:55 25 4
gpt4 key购买 nike

我需要创建一个带有按钮的 jsp 页面 - 单击该按钮后,它将在 Outlook 中打开“新电子邮件”窗口,其中填充了“收件人”、“主题”和“正文”字段。

我通过 servlet 实现此功能,因此当用户单击按钮时,将调用 servlet,并从 servlet 类的 doGet() 调用以下代码。

当我尝试将其作为独立的 java 应用程序进行测试时,效果很好,并且新的消息窗口完美打开。但是当我尝试通过 jsp 表单打开它时,出现异常。

异常:

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

我已经包含了以下 jar :

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文件夹中。所以请确保你这样做。

关于java - ClassNotFoundException : org. eclipse.swt.widgets.Display,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22473833/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com