Run non GUI Java program on Server [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm really experienced when it comes to Java SE, but aside from helping out on a Java EE program running on a application server like JBoss i have no experience in running Java server side, only PHP applications.
I want to do the following:
I just want to write a Java program, that listens on a port (if there are incoming connections) which has to run on a server. It's no web application, there's no GUI or any stuff like that. It just needs to be approachable via the net from for example a desktop application.
What do i need to run a simple Java program server side which can accept requests as simple as possible? (Server recommendations for this simple task appreciated).

If you don't need the full stack of webserver, no. You just need the capability to run a java process.
Check the API for
ServerSockets http://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html
and
Sockets http://docs.oracle.com/javase/7/docs/api/java/net/Socket.html
which will just allow you to open a specified port and do with it as you please.

it's really simple with an embedded jetty server. As simple as:
Server server = new Server(8080);
server.start();
server.join();
You just need to implement a handler.
public class MyHandler extends AbstractHandler{...
and add it
server.setHandler(new MyHandler());
see http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html

Related

Is it possible to register a Domino Server with the Java API or C API? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
We are well on our way to Dockerizing Domino. In fact, we have a Domino Docker running in IBM Cloud (bluemix) that replicates with on prem.
What we want to be able to do is automate the standing up of a Domino server.
In our script, we are thinking of calling a custom program we can build that will use either the C API or Java API to register a new server, deploy a XPages (JSF) application to it, and start the server, replicate over the common user directory (names.nsf) from the master server.
Currently, we started the Domino Container in CentOS in listener mode. We registered the server on prem, and copied over a bunch of files (server.id is one of them) and edited confirmation to manually configure it. We want to automate this process.
Any insights on how this can be better accomplished? any api references you can share to get us most of the way there?
Yes, this is possible. We have done this in Lotusscript using LS2CAPI.
As we are accesing API functions, this is also possible using Java. Not sure, if domino-jna already includes the needed Api calls, but this can be implemented. Take a look at github for Karsten Lehmann and domino-jna.
domino-jna can be used from XPages as well.

How can I convert a standalone Scala application to runnable SOA? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am working on a scala-spark application which I would like to migrate to the runnable service model.
For the application could be invoked but I would like to run the application as a service which could be stopped and stopped from a Unix/Linux command.
Also, deploy the application on webserver and build Rest APIs.
Would writing a wrapper in Linux/Unix make sense to run it as a detached daemon process?
Can someone guide me what is the right tools if any which could help me in rapid development?
Thanks,
Az
You could :
embed a REST API or whatever service you want into the driver
use the livy project as you can see in the paypal presentation ["spark compute as a Service"][1] https://spark-summit.org/2017/events/spark-compute-as-a-service-at-paypal/
As for start stop restart and so on you need to track the applicationid to kill (assuming you are using yarn)
To be stopped and started, you could use the thrift server and feed in straight SQL commands. You could run a spark job that opens a listening port as well, which is what Zeppelin does.
To deploy the application it depends what language you like but you could use flask with Python or Play with Scala.
Also, you might want to look at Zeppelin, you can write the jobs on notebooks and then use the Zeppelin API to pipe in http requests. Actually if you go this route, I'd be interested to look at your web service client because I'm goinng to be doing the same thing
https://zeppelin.apache.org/docs/0.7.0/rest-api/rest-notebook.html

Best way of client server communication in Java [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am building an application where in the requirement is that, there is a main server, which will send signal to client server, based on this signal the client performs certain action and send back the response to the main server. Here there will be only one main server and can be multiple client servers. At a given time the main server can send multiple signal to multiple clients.
I am presently planning to do this using socket programming in Java using two ports. Do let me know the best way of achieving this? and also do we have any good existing API's that can be used?
Take a look at RMI: https://docs.oracle.com/javase/tutorial/rmi/ If you want something based on sockets/TCP/UDP/etc, writing something with Netty may be good solution -> http://netty.io/ (they have useful examples).
I would also recommend to consider plain Java Sockets if planned communication beetween server and clients is not comlex and you do not need all this stuff which is provided by libraries like Netty.

Communication Java to NodeJS? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am exploring various ways that allow Java to connect and communicate with NodeJS. An example of what I am trying to achieve, is for example call Java methods from NodeJS, while allowing the Java method to manipulate Javascript objects. I know the JSObject class is helpful for this purpose. I have also heard so far of Dnode and ZeroMQ. Have you heard of or do you have experience in doing something similar? Would you suggest a way on how this communication Java to NodejS can be done?
I would go with an agnostic implementation.
A rest server on node js, maybe using restify listening for messages
A http client on the java side as httpclient to send messages to node.
this will also make it dead easy to test node implementation with curl and static requests; will enable you to implement authentication later on using any standard mechanism from oauth to basic and will let you change the client and the dispatcher independently later on
also you will be able to put any kind of standard load balancer in between, should you need the node app to scale.

How to run java files in a web server [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i am creating an android application which has got two parts a client part and a server part. So the client will be asking the serveer for a particular data and server need to give it back to the client. My question is how i can run this server program (jar file ) in a web server. I have tested it locally using eclipse but i need to know how i can put this into a web server and run it there. So that the client can use a data connection and connect to the server program and get back the respose from there Sorry for the inconvenience caused and a thank you in advance
From the way you describe your server it sounds like a simple .jar file that you built. If this is the case, you can simply deploy the jar on any compatible computer (or webserver) that you have shell access to.
Build runnable jar in eclipse
Place the jar file on some server
Make sure the server has java installed (same java you used to build your runnable jar)
Run the jar using java -jar path_to_jar.jar
To answer your question, you can run this in the background of a server running other services as long as you pick a port that isn't already in use. Make sure you enable port forwarding on your router/firewall (if you have one) if you want to access the service externally.
You will require Tomcat server for running Java ,jsp
To start with hosting this link might help you.
How to host a JSP website on a webserver?

Categories