I have a Java JSVC application in which I would like to expose a web/REST API from.
What is the simplest way to do so?
Every time I try to find a simple tutorial it wants me to install at least a framework and a web server (jersey, tomcat, Java EE, gradle, glassfish, spring and maven has been mentioned a lot)...
Is there a lightweight way to do it with as few dependencies as possible?
My app needs to be able to be deployed as a standalone daemon/service. It would be problematic if people had to set up a tomcat webserver and/or other stuff.
Isn't any Java app be able to bind to a port and listen for data?
Many people around Spring say that Spring is exactly that - a lightweight server component for people that don't want to dive into the application server business.
Of course, a framework like Spring is still not lightweight; for example compared to a simple ServerSocket or the Jetty framework mentioned above.
But there is one thing to keep in mind: http traffic and REST do not come for free. Those terms means complexity; and dealing with that complexity is heavy lifting in order to get it right. Of course, it might be possible to pull together something on your own; but if your product attracts users; step by step you will be faced with more requirements. And all of a sudden you have to consider performance, security, standards ...
Thus: keep in mind that a "small" solution might solve your current problem. But that you might pretty quickly need "more than that". And all of a sudden, you are constantly re-inventing the wheel (and probably the wheel you are building is very much deficient compared to off-the-shelf solutions).