Java中的类显示错误



我正在尝试在Java应用程序(在NetBeans上)中获取当前显示,但它一直在抛出一个例外,我在网上没有任何有用的东西。

这是我的代码:

    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        try {
        System.out.println("Step 1 in Execute in EmailHandler.");
        Display display = Display.getCurrent();
//        Display display = PlatformUI.getWorkbench().getDisplay();
        System.out.println("Step 2 in Execute in EmailHandler.");
        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");
        System.out.println("Step in Execute in EmailHandler.");
        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", "g.dw@hotmail.be"); // Empty but could also be predefined
        setProperty(mail, "Bcc", "test@gmail.com");
        setProperty(mail, "BodyFormat", 2 /* HTML */);
        setProperty(mail, "Subject", "Test mail");
        setProperty(mail, "HtmlBody","<html>Hello<p>, please find some infos here.</html>");
        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"/*"Send"*/); // Or "Display" in place of "Send"
        }
        catch (Exception e) {
            JOptionPane.showMessageDialog(null, e);
        }
        return null;
    }

例外发生在线路Display display = Display.getCurrent();正如您在下一行中看到的那样,我尝试以另一种方式获取当前显示。

这是我使用Display.getCurrent()方法遇到的错误:

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no swt-pi-gtk-3139 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:123)
    at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:19)
    at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63)
    at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54)
    at org.eclipse.swt.widgets.Display.<clinit>(Display.java:122)
    at costPolicy_v1.EmailHandler.execute(EmailHandler.java:35)
    at costPolicy_v1.CostPolicyFrame.startButtonActionPerformed(CostPolicyFrame.java:304)
    at costPolicy_v1.CostPolicyFrame.access$300(CostPolicyFrame.java:27)
    at costPolicy_v1.CostPolicyFrame$4.actionPerformed(CostPolicyFrame.java:169)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6535)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6300)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4891)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4713)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
    at java.awt.Container.dispatchEventImpl(Container.java:2280)
    at java.awt.Window.dispatchEventImpl(Window.java:2750)
    at java.awt.Component.dispatchEvent(Component.java:4713)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

这是我的进口:

import java.io.File;
import javax.swing.JOptionPane;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleAutomation;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.ole.win32.Variant;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;

有人知道解决方案吗?

非常感谢!

我发现了我的问题!我添加了SWT.Jar作为罐子,而不是整个库。现在,我将其添加为库,不再抛出例外!: - )

相关内容

  • 没有找到相关文章

最新更新