Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run chat example using Maven or Gradle? #946

Open
PhilipRoman opened this issue Nov 21, 2019 · 2 comments
Open

How to run chat example using Maven or Gradle? #946

PhilipRoman opened this issue Nov 21, 2019 · 2 comments
Labels

Comments

@PhilipRoman
Copy link
Collaborator

I was looking for an alternative to the chat server instructions (https://tootallnate.github.io/Java-WebSocket/) mentioned in #937.

Apparently, running the examples used to be as simple as this:

ant
java -cp build/examples:dist/java_websocket.jar ChatServer
java -cp build/examples:dist/java_websocket.jar ChatClient

When I tried building it now using Maven or Gradle, the classes under src/main/example/ weren't being compiled so I had to manually javac them and then download SLF4J dependency jars.

Maybe there should be a simple build task so you can do, for example gradle example or mvn example to run the examples.

@marci4
Copy link
Collaborator

marci4 commented Nov 21, 2019

I like the idea with mvn example! :)

@dota17
Copy link
Contributor

dota17 commented Aug 21, 2020

1、 update pom.xml line 166:
src/main
After pom.xml was changed, directly mvn clean install , it would fail with follow message:
[ERROR] Failed to execute goal biz.aQute.bnd:bnd-maven-plugin:4.3.1:bnd-process (default) on project Java-WebSocket: The default package '.' is not permitted by the Import-Package syntax.

2、 add package to the java of example :
mvn clean install , it was successful. And the classes ware in the dir of example:
mvnbuild_20200815150557
Ex : dota17#15
This is just an example how I use it, I hope it can help you.

3、 Add the dependency of slf4j-api-1.7.25 in the libs:
/c/code/local/Java-WebSocket/libs
abc@desktop MINGW64 /c/code/local/Java-WebSocket/libs (exampleBuild)
$ ls -lrt
total 60
-rw-r--r-- 1 abc 197121 41203 2月 11 2020 slf4j-api-1.7.25.jar
-rw-r--r-- 1 abc 197121 15257 6月 28 16:11 slf4j-simple-1.7.25.jar

4、 We can run the example with java:
cd target/classes/

$ /c/code/local/Java-WebSocket/target/classes (exampleBuild)
java -Djava.ext.dirs=/c/code/local/Java-WebSocket/libs example.ChatServer

5、The return result :
ChatServer started on port: 8887
Server started!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants