2016-06-17 3 views
0

Java 응용 프로그램 (Netbeans)에서 현재 디스플레이를 가져 오려고하지만 웹에서 아무 것도 찾을 수없는 예외가 계속 발생합니다.클래스 표시 오류 (Java로 표시)

@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", "[email protected]"); // Empty but could also be predefined 
     setProperty(mail, "Bcc", "[email protected]"); 
     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() 방법으로 얻을 오류 :

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; 

누군가가 그것에 대한 해결책을 알고 있나요 : 여기

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) 

내 수입은?

대단히 감사합니다!

답변

0

내 문제를 발견했습니다. SWT.jar을 전체 라이브러리가 아닌 jar 파일로 추가했습니다. 이제 라이브러리로 추가 했으므로 예외는 더 이상 발생하지 않습니다. :-)