问题
I've been attempting to use the Java library, jPushbullet2. One of its dependencies is "javax.websocket". I've searched through the site that the websocket API is located and haven't been able to find a jar to download and use. Does such a thing exist?
I also noticed that the author of jPushbullet2 mentioned Tyrus, which is a "reference implementation", presumable in reference to javax.websocket. Is this what I need? I've already added it to my project's build path along with the other dependencies and have tried to run the first push sample:
public class FirstPush {
public static void main(String[] args) throws PushbulletException {
PushbulletClient client = new PushbulletClient( "o.F8y8swnMc4MESY5rE1aUw8cFLloFH2uH" );
String result = client.sendNote(null, "My First Push", "Great library. All my devices can see this!");
System.out.println( "Result: " + result );
}
}
However, this unfortunately results in the following errors:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/websocket/CloseReason$CloseCode
at practice.FirstPush.main(FirstPush.java:10)
Caused by: java.lang.ClassNotFoundException: javax.websocket.CloseReason$CloseCode
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 more
This makes sense, since I don't have any jars from javax, only from Tyrus.
I'm very new to the external-library scene, as you probably can tell. Thank you for the help!
回答1:
I had to add 2 jar files to my project: javax.websocket-client-api-1.1.jar
and tyrus-standalone-client-1.9.jar
to make it work. A simple google search did the job:
https://jar-download.com/explore-java-source-code.php?a=javax.websocket-client-api&g=javax.websocket&v=1.1&downloadable=1
and
https://jar-download.com/explore-java-source-code.php?a=tyrus-standalone-client&g=org.glassfish.tyrus.bundles&v=1.9&downloadable=1.
来源:https://stackoverflow.com/questions/41906617/where-to-find-javax-websocket-jars-for-use-in-project