本文介绍了在类路径中添加库后,找不到Jetty WebSocket类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Jetty与远程服务器进行通信,使用websockets。
我在Eclipse中开发它,但是我无法编译任何示例代码。
这就是我所做的那样

I'm trying to use Jetty to communicate with a remote Server, using websockets.I'm developing it in Eclipse, but i can't compile any sample code.That's what i've done

我下载了最新版本的Jetty,我已经在classpath中添加了start.jar。
这就是我在样本类中包含的

I downloaded the latest version of Jetty, and i've added start.jar in the classpath.That's what i've included in the sample class

import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;

等等。问题是Eclipse无法解析这些导入。我应该怎么办?

and some more. The problem is that Eclipse can't resolve those imports. What should i do?

推荐答案

从你的...中删除 start.jar 项目,这只是一个启动独立Jetty分发的启动jar。

Remove the start.jar from your project, that's just a bootstrap jar for starting the standalone Jetty distribution.

您需要的JAR在$ $ c * c * / websockets / 目录。

The JARs you need are in the ${jetty.dist}/lib/websockets/ directory.

[joakim@lapetus jetty-distribution-9.0.4.v20130625]$ ls -1 lib/websocket/
websocket-api-9.0.4.v20130625.jar
websocket-client-9.0.4.v20130625.jar
websocket-common-9.0.4.v20130625.jar
websocket-server-9.0.4.v20130625.jar
websocket-servlet-9.0.4.v20130625.jar

所有WebSocket应用程序

始终包含在您的项目中:

Always include in your project:


  • lib / websocket / websocket-api-9.0.4.v20130625.jar

  • lib/websocket/websocket-api-9.0.4.v20130625.jar

WebSocket客户端要求

添加在您的项目之后:


  • lib / websocket / websocket-client-9.0.4.v20130625.jar

  • lib / websocket / websocket-common-9.0.4.v20130625.jar

  • lib / jetty -io-9.0.4.v20130625.jar

  • lib / jetty-util-9.0.4.v20130625.jar

  • lib/websocket/websocket-client-9.0.4.v20130625.jar
  • lib/websocket/websocket-common-9.0.4.v20130625.jar
  • lib/jetty-io-9.0.4.v20130625.jar
  • lib/jetty-util-9.0.4.v20130625.jar

WebSocket Servlet要求

如果您正在编写一个将挂接到您的WAR / WebApp的WebSocket服务器,那么您将需要:

If you are writing a WebSocket server that will hook into your WAR/WebApp, then you'll need:


  • websocket-servlet-9.0.4.v20130625.jar

  • websocket-servlet-9.0.4.v20130625.jar

你永远不会需要 websocket-server-9.0.4.v20130625.jar 因为这是Jetty Server用于提供对WebSockets的支持的内部/实现特定JAR。

You will never need websocket-server-9.0.4.v20130625.jar as that is an internal / implementation specific JAR that the Jetty Server uses to provide its support for WebSockets.

这篇关于在类路径中添加库后,找不到Jetty WebSocket类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 14:06