2012-08-16 58 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