2012-08-16 91 views
0

我試圖打開使用SWT瀏覽器,並收到以下錯誤小程序嵌入網頁...困在這裏..can任何一個小程序嵌入頁面幫助運行從SWT瀏覽器(Mozilla的)

java.lang.NoClassDefFoundError: com/sun/deploy/services/Service 
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) 
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(Unknown Source) 
    at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source) 
    at com.ivb.coep.vtu.plc.OpenBrowser.<init>(OpenBrowser.java:33) 
    at com.ivb.coep.vtu.plc.OpenBrowser.main(OpenBrowser.java:39) 
Caused by: java.lang.ClassNotFoundException: com.sun.deploy.services.Service 
    at java.net.URLClassLoader$1.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 

回答

1

Browser support for applets varies by platform:

Windows: As of Eclipse/SWT 3.5, applets can be viewed in a Browser if all of the following conditions are met:

1) For Browsers created with style SWT.NONE, the installed IE version is 7.0 or newer

2) For Browsers created with style SWT.MOZILLA, the installed XULRunner version is 1.9.2.x or 3.6.x

3) The installed Java plug-in is Sun JRE 1.6u10 or newer, with the Next Generation Java Plug-in enabled (this plug-in is enabled by default when the JRE is installed)

4) The application is launched with the same JRE that provides the installed Java plug-in

5) The application adds the JRE's plugin.jar, deploy.jar and javaws.jar jars to the JRE's boot classpath. For example, to launch eclipse: eclipse -vmargs -Xbootclasspath/a:"C:\Program Files\Java\jre6\lib\plugin.jar;C:\Program Files\Java\jre6\lib\deploy.jar;C:\Program Files\Java\jre6\lib\javaws.jar"

Linux (Mozilla): Applets can be viewed with Mozilla-based Browsers as long as the Mozilla Java plug-in is found at runtime.

OS X (WebKit): Applets cannot be viewed with WebKit-based Browsers on OS X because the launching of a JRE to execute the applet collides with the JRE that is running the application.

參考:http://www.eclipse.org/swt/faq.php#browserapplets

檢查上述鏈接並驗證該頁面中的所有規定的標準,以便applet在swt瀏覽器上運行。我猜你應用程序的類路徑中缺少一些JAR文件。

尤其是這個java.lang.NoClassDefFoundError: com/sun/deploy/services/Service。這個類屬於deploy.jar。

+0

我有這個chk並下載了xulrunner的正確版本,例如Mozilla Xul Runner 1.9.2.26,但是現在當我通過cmd註冊它時,它不會給出任何錯誤,但是在運行程序時我收到異常 – Ruby 2012-08-16 07:45:16

+0

線程「main 「org.eclipse.swt.SWTError:沒有更多的句柄[無法檢測到註冊的XULRunner使用] \t at org.eclipse.swt.SWT.error(Unknown Source) \t at org.eclipse.swt.browser.Mozilla。創建(未知源) \t at org.eclipse.swt.browser.Browser。 (未知來源) \t at com.ivb.coep.vtu.plc.OpenBrowser。 (OpenBrowser.java:18) \t at com.ivb.coep.vtu.plc.OpenBrowser.main(OpenBrowser.java:39) – Ruby 2012-08-16 07:46:00

+0

請查看http://www.eclipse.org/swt/faq.php# howdetectmozilla和這個http://www.eclipse.org/swt/faq.php#specifyxulrunner。嘗試使用顯式路徑到xulrunner,像這樣'-Dorg.eclipse.swt.browser.XULRunnerPath =/path/to/XulRunner' – 2012-08-16 08:00:42