communicate with another applications on the same machine - java

Hi Stack Exchange Experts,
I am working on a task, that requires me to communicate with another applications on the same machine.
the machine is a Windows 7 laptop.
There are in total 3 applications on the laptop. Their specifications are given below:
First application is coded in java and runs on a local Tomcat at port 6060
Second application is coded in java and runs on Tomcat at port 8080
Third application is coded in java and does not have Tomcat. It is a static web application.
Since application 1 and 2 are running on Tomcat, I have used HTTP to commicate with each other. However, since they are on the same machine, is there any ohter way for them to commincate with each other?
Application 2 needs to communicate with application 3. What is the best way for this communication.
Please let me know if you require any further information to answer my queries.
Thanks.

Related

Running java application as windows service

I have a Java Application(works as server for a client application) with a GUI. This application has to run always even after restarts of the server.
I have created a windows service using Apache daemon for this purpose.
When the server starts I can see my services running as system service. But when I open the GUI of the application another instance starts.
I need the GUI to be attached to the same instance which started after restart, is this possible.
A Windows Service (as well as daemons on Unix-systems) can't run with a GUI because it starts without a Window Management System like Windows Desktop or KDE, Gnome, etc. I'm actually surprised that your application starts as a service because attempts to start GUI-elements should lead to an error.
You have to separate the GUI from the server components. The GUI then needs to communicate with the server by some protocol. Because you already have finished your application I suggest RMI as protocol of choice, that should be the easiest to implement because you essentially just have to add some interfaces to your classes to get RMI on its way instead of adding a complete layer of complexity by your own (an additional server to receive commands from the client, etc.).
RMI can be set up to only listen for connections from localhost, so in terms of security you should be good as well.

JMS Wildfly implementation

I'm writing an application that runs as a daemon and makes restful request periodically, I'm trying to implement a system where I have another application (preprocessor) that will be sent the JSON responses from the daemon.
My plan is to use JMS for this, my understanding is that I can send the restful responses I receive in my daemon.jar to a Queue using a JMS provider, I've been looking into using JBoss.
So my understanding now is that I need to run a JBoss 7 Application server, or a Wildfly AS, I plan to run this server on a raspberry pi 2 for testing purposes, Have I got this right?
Regarding the client and receiver, Do they both need to be running on the server? I'm confused by this, can I have the Wildfly AS running on the pi, have the sender running on another machine and the receiver running on a 3rd machine?
Do my sender and receiver need anything specific on them to communicate with the AS other than maybe some libs for Wildfly?, I've seen Hornetq mentioned a few times, but am unsure how this fits into the process.
Finally got this working, I couldn't find a start to finish example of setting this all up, but managed to piece it all together from different examples.
the Sender(Producer) and Receiver(Consumer) don't need to be running on the server, I have all 3 running on different machines, they have to know the address of the Wildfly AS and the name of the queue(HornetQ) they are connecting to.

Run application on server by application on client computer

I have an Linux server, and i have 2 Java applications.
1- ServerApp.jar. This application is on my server.
2- PcApp.jar. This application is on my computer.
May i make ServerApp.jar application run, by click on button in PcApp.jar application?
There are ways to download and execute the remote jars at client place.
But for your problem of invoking some operation on remote machine itself, you'll have to fall back to RMI or services implementation on server side and trigger them inside PcApp.jar

Where does the server side of programs run? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
If I had program and multiple clients connecting to a single server where exactly would be a good place to run the server from?
Is there a way to run the server side of the program from a website for example, since websites are servers and could always run the program? Running a server from a home computer doesn't sound like an option that most people would choose because of obvious reasons. For example: where would a small scale indie online game run their server side from?
If I had program and multiple clients connecting to a single server where exactly would be a good place to run the server from?
a computer?
Is there a way to run the server side of the program from a website for example, since websites are servers and could always run the program?
a website is a kind of application run on a server, they are not servers.
Running a server from a home computer doesn't sound like an option that most people would choose because of obvious reasons.
there is no "obvious" reasons why. Many web services started self hosted, and Internet has been built with service providers that are not in datacenters. I do host many services at home and they are accessible from Internet.
For example: where would a small scale indie online game run their server side from?
You have many choices:
a server on a pretty good Internet connection at your home/workplace/garage (with enough bandwidth and low latency),
a virtual server hosted in a datacenter service's provider,
a virtual server like AWS/EC2, Google apps, Azure...
a dedicated server in a datacenter,
a grape of dedicated servers and their caches etc.. with many engineers making the thing work perfectly
...
it all depends on the money you got!
websites are NOT servers. Servers are servers, and host websites (among other things). The "server" is the thing that people connect to, aka a physical machine. This machine may or may not be the same machine as your client.
For an indie game, it depends on your connection. Your options are to either run it yourself out of your room, which is entirely fine provided you have a good internet connection, or to RENT server space, which is some cluster somewhere that you rent access to. These usually have external tech support for when things go wrong.
If you are testing code, run the server software on your local machine. once you get it working, run it on a different computer on your local network. once that works, run it on an external network.
Also, for reference, I run a web/file/computational/etc server out of my bedroom. It keeps me warm in the winter.
A Java web application runs inside an application container such as GlassFish or Tomcat (there are many others). This container runs on a physical server. Typically the physical server will be hosted in a server room of some kind. This can either be at the companies location or, more common for smaller companies, remotely hosted. A remotely hosted server can be a physical piece of hardware you own or more commonly now just a machine you rent, in fact most servers you'd probably rent now will be virtualized.
You can run a web server from a home computer, I've done it for many years, but it has some downsides. You typically have a fairly poor internet connection and a lot of ISP's don't like you hosting servers.
I recommend you look at renting a virtual server.

Running a Java project remotely

I've got this new project at work. We are using Eclipse for the project. There are two run configurations, server and client. I have to launch the server and the client independently, and connect to the server using the client. Now, it so happens that this has to be done on both Windows and Linux. (four possible combinations: WS-LC, WC-LS, WS-WC, LS-LC, where W-windows, L-linux, C-client and S-server)
I have Linux on my machine (in which Eclipse is running) and run Windows on a VM. Is there a way I can make Eclipse launch the application in the VM?
I understand I have to build the application locally to a shared folder and send a launch command to windows (using openssh?, not sure). What are the best practices used in this scenario.
EDIT: I need to use this during development, to test my changes to the code. The same application provides both client & server. (yes, horrible, i know :X )
You can publish the server functions as JMX Beans using the MBean interface standard. Then use JMX Console to remotely connect to the server JVM and launch the application.
Eclipse has integration points for remote servers, look to "tomcat configuration" for an example of how it integrates with one remote server.
Whether your application can use an existing server integration solution or not depends heavily on details which aren't present. If you want to actually launch a stand-alone Java process from your remote machine, you generally need a program to capture the request and launch the process.

Categories