user3038404
user3038404

Reputation: 361

Java Websocket with tomcat localhost

I don't know if this is the right one to post to, correct me and I will switch!

I am using java with eclipse photon with Apache tomcat 9. I am making a application that will be connected to server (local host or make a local host on the pc) and then I will be able to send things to this local host node to store on a document. I was woundering 2 questions before I embark on this adventure that I haven't found the answer to.

Number 1: I want to use websockets, and I have tried to find an API from tomcat website but can't find it. I have looked at bunches of API's, there is a lot of free ones, but they are confusing me a bit. There is the javaEE websocket, then their is also a tomcat version (although I'm having a problem finding that now lol), but I just want it to use localhost. In all the tutorials I have watched they use javaEE (expected), but now I don't know if tomcat and websockets work in anything other then javaEE.

number 2: My application relies on there being a local host on the machine it is running on. If I configure tomcat, and have my Server file in my project explorer for eclipse and have that inside my project folder that contains the scripts etc, when I finish and compile my application on installation for the user, I am assuming I will have to create a local server on the users machine on installation; but I was woundering(hoping) that is it simpler, and the local server folder (that I saved within the compiled file that the user will download) that contains the local server configuration will be carried over to the users version when they download. I am woundering this because of setting up ports etc.

Any wisdom or tutorials please link!

Upvotes: 0

Views: 1193

Answers (1)

Mohsen
Mohsen

Reputation: 4643

For number1 you can implement pure websocket for java with helping of this https://www.baeldung.com/java-websockets.

For number2 I suggest you two options:

  • Use an embedded version of tomcat then you can create a jar file and give it to your users to run it in their localhosts.
  • Write a ant task that when users run, your project files and resources copy to tomcat.

Upvotes: 1

Related Questions