Communicating between Adobe Air or browser and Java Web Start - java

We're designing an application and the client has requested that a portion of their app stay in Java Web Start and another portion be in a browser. I'm thinking about AIR as an alternative to the browser because that may give us more features b/c we don't have to stay in the browser security sandbox.
How would I go about having an Air app talk to a Java Web Start app? Do they have to talk through a server? I guess potentially you can just create a socket connection between the two.

You've named the two best options already -- create a socket connection or implement a server API. There are other hackety methods you could use too -- for example, if you're using AIR, you could have both the Java app and the AIR app read/write to a file on disk for communication. This has a host of other issues (file lock when reading/writing) that a socket connection doesn't have, though.

Related

Can i host my ServerSocket or Java file somewhere on the web?

Heyy guys. I'm writing a chat application in java, works pretty well. But can i somehow host my Server file or the Serversocket on the web? I want to make it so my friends from other pcs can use the client and connect to the server file which is hosted on the web. Is that possible? Can i host the File/socket online?
When you run a java application that opens a ServerSocket, it opens a port on your local machine and starts listening for incoming connections. What you do with those connections is up to the implementation of the java code that you write.
The "web" is much less foreign than you are making it out to be. Your own computer can be on the web that you're talking about and people can connect to your chat service. Or you can choose to host it on something like an AWS server.
The following approach is assuming you are behind a pretty standard NAT config.
Once you run your java application, you need to make sure other computers can see you, either inside your LAN or outside on the internet. You want to start testing from as close to your computer as possible, then start expanding outward.
First you need to make sure that your computer's firewall is actually allowing connections on the port that your java application is listening on.
Opening ports in the Windows Firewall
Setting up and opening ports in Linux
Now computers on your LAN will be able to connect to your java program. Now you need to go one layer out, and port forward your router. This is much less standard so I can't help you too much, but Google can.
At this point, anyone on this internet, knowing your external ip and what port your java application is listening, can connect to your service.
If you chose to host this on an third party hosting service, you'll need to go through similar steps, but there may be slight differences that you can either ask about, or again Google is a great resource.

I want to make HTTP call for Desktop application (can call from Command line)

I have one Desktop application and i want to call that applicating using command line from anothr web application. is it possible ?
A desktop application being the target of a call is usually a bad idea because in order to succeed the desktop application must be visible from where you want to reach it. This might or might not be a problem.
If the 2 computers are on a LAN, this should not be a problem. If the desktop application is behind a router or firewall, this requires opening and forwarding a port to the computer the desktop application is running on. This might not be feasible or doable (e.g. you have no permission to change firewall and routing settings) in many cases.
Best approach would be for the desktop application to contact the web server.
But if you really want to do otherwise, the desktop application should create a ServerSocket and listen for incoming connections, or start an embedded web server. There are other possibilities of course (e.g. RMI).

How to host a java application (without using webservices)

I made a game with sockets that works fine on my machine, and now I would like to run the server on a host so that anyone can join in at any time.
All I'm finding are services for web applications, mine is just a swing application that can run by itself.
What kind of server can I use (instead of my own machine)? Would I need to change the code or is it possible to just find a host that runs my server application as is?
Also, note that for now I kept it simple, there is no data storage.
Take a look at Amazon EC2 cloud. Essentially what you're looking to do is acquire a public IP address (an be done from the Amazon EC2 admin console). You'll be installing java and then opening a port in your security settings to allow traffic to whatever port your game server is running on.
EC2 is free for low volumes of usage for the first year (new accounts only) and I've had fairly good luck with them in terms of downtime and affordability.

Uniquely connect an android application to a java applet on pc

I want to connect my android application to an applet which is running on my pc on Google chrome on Wi-fi.. where my phone works as a wi-fi hotspot and pc as the connected device. I want the connection to work uniquely as I want commands to be passed from my application to the specific applet, on the execution of which my applet does specific tasks. Please tell me the APIs which I can look in both Java and Android or the technology I have to use to make it work..
You need to use any program, such as wamp server, to make your computer to be a localserver. It will install PHP 5, MySQL and Apache. In other hand, you will also need a little bit of knowledge in Php language to create you own web services.
Another thing you need to be aware is that to handle you connection between server and device (and by this I mean which IP you are going to use) you will have a little headache; but first things first..break your problem in little parts thus will be easier to solve them.
I recommend this tutorial.
I think the simple way to connect these two softwares is using UDP.
It is fast, it is easy to program but it is generally unreliable according to TCP. But it is already local network. I dont think that is a case you need to take care in your local wifi network.
So take a look at this tutorial http://tutorials.jenkov.com/java-networking/udp-datagram-sockets.html
There are other ways like https://www.alljoyn.org/. It has more functinality but more complicated.
You must install Server on your PC(Apache httpd or apache tomcat or other based on your interest). A server listens to request from clients. When your mobile is connected to your pc(doesn't matter wire or wireless), you can make a request to an url(say, localhost:8080/welcome) from your app.
Create an applet and connect it with your web application(in the server) using java.net.URL and java.net.URLConnection.
On performing some operation on the client, call the url of the server application and forward the response to the applet.

Java jar application and java web application communication and implementation

I have a multiplayer game server application written in Java which connects to player clients when they join the multiplayer game via a socket. The server application (a JAR running in the JVM) is listening to a port (e.g. 9999) for incoming connections from clients.
I want to add a website to minitor the entire project which contains information taken from the running game server(s). One way would be to open a socket from the site (a PHP socket for example) to the gameserver (Java) and implement a custom protocol for taking data from the server. But that method is time consuming as I need to add support for each type of datum I want to pass to the monitoring website.
I was thinking if there is a way to write the site in Java and simply communicate with my gameserver via a direct link. RMI would be a solution I assume since both my JAR and my WAR can communicate through it, but isn't there some better way to build both the web application and the gameserver application inside the same JAR file? So that when my gameserver runs, the web application runs too?
this looks to me as the fastest way to have an admin console. Just transform your server into a war application which contains both your game server with an open socket for clients and your administration pages. To start your server simply drop it into a tomcat.
A cleaner approach which does not require some self-created protocol would be to have your server use mbeans for all key objects which you would like to admin. But this needs some coding.
Cheers, Sven
You should have an embedded web server in your game server. Try Jetty (http://jetty.codehaus.org/jetty/). It's quite easy to embed in any java application.

Categories

Resources