Communication between a desktop app and a web app? - java

I'm interested in having a desktop application send messages to a web app. Specifically, the desktop app, written in Java, needs to send messages to a Javascript function that will be running in a browser. The messages only need to be sent one way. Also, both programs will be running on the same local machine. I can set up a local development server if necessary.
I'm new to networking and web development and I have no idea how to approach this problem. Can anyone offer any suggestions?

I think the appropriate way to do that (if not the only way) would be to go through a server both apps talks to

The enterprise architecture way I recommend you do is:
Put the common information into a webservice.
The website sends information, possibly via ajax or by navigating to a different URL or doing a form POST to the webservice.
The desktop app will start up and will subscribe to the webservice. The webservice will notify the desktop app once it has an update. (note that the desktop app, might need to poll for updates).
That approach is how services such as flikr, twitter etc use.
The light weight (ie smaller architecture) way of hacking this is to make your website have an RSS feed that your desktop app subscribes to. The desktop app gets updated via the RSS feed.
That approach is how services such as news websites will send updates to readers. See google reader as an example RSS client. RSS has an adavantage of supporting generic rss consumers like MS outlook or google reader from the start, where as webservices are likely to be more flexible and cleaner in the long run.

why does the desktop app need to talk to javascript? What is it you are actually trying to do? Send or receive data to or from a database? Run some business logic on the web app? These things are typically done from a desktop app to a website using soap or rest.
is the browser embedded somehow in the desktop app? Or could is it just running as a separate process? It seems like audio processing should really run in the desktop app.
However, assuming that the browser is running as a separate app, you should be able to send messages to the browser through the query string. The desktop app could fire up the browser, point it to a url and pass some parameters to it. THen javascript can process those parameters. Google whether jquery can process query string parameters.

Embed a simple container like jetty then use Jersey or a Simple Servlet

Related

Spring webapp: sending notifications to java and android clients

I recently started developing my first web application with Spring and I'm stuck with a question I could not really find an answer to. What I have is a simple Spring MVC application running in tomcat which provides data in form of JSON, XML or binary via REST. This service is consumed by two clients I developed, a simple Java desktop application and an Android app. So far the clients only got information about new data by polling.
What I want now, is a way for the server to send notifications/messages to the clients when new data is available. For the Android client it would be good if the notifications could received anytime, not only when the app is currently open of course. I found lots of information for JavaScript client code but very little really useful, up-to date input about what the options for java and android clients are.
It would be really great if someone could give me some idea what would be the best way to achieve what I want (ideally something which integrates well with Spring on the server side), what protocols/libraries/frameworks to use, maybe even point me to some example or tutorial, how to implement this on server and client side.
Thanks in advance for any input.
For android or mobile devices, Google Cloud Messaging is the preferred way of sending messages to applications running on devices.
Example : spring gcm server side project and a sample tutorial.
For desktop apps, either poll regularly the server or run something in background like crontab or active-mq to check the messages and start the desktop app.
WebSockets are the best solution. check the implementation in java in the server side

Web server/db online to communicate with android?

I'm new in android and i want to know if there is some server / web service online that o can use to update and communicate with my app?
example: I have the app "message" in 5 phones so I want to communicate with all of them, if the phone 1 send a message all device must receive notification.
There is something that I can use maybe free?
You have many options to accomplish this goal, and most provide some free level of support.
In general if you want to "push" notifications to android devices, you can either directly use or use some provider that uses Google Cloud Messaging.
Using this approach directly means you need some web server to send request to, which will then forward a request to Google, which will then forward your "message" to the devices you want to reach. There are many options for free hosting of (smallish) web services. IBM's BlueMix and Heroku come to mind. So if your are comfortable writing web apps, this might be a good choice. I have used both (for Ruby on Rails backends to mobile apps) and found both very good, but am currently using Bluemix.
I believe Bluemix along with Parse also offer mobile data storage and easy access to Push notifications to both Android and iOS. I am currently using Bluemix via Ruby on Rails and pushing messages directly to devices via GCM and don't have much experience with those particular offerings.

iPhone/iPad app development connect to a java http server

Ok so I am still new to Objective C and currently learning it. I wanted to make an app where people can login and submit data to a database. I have research and found that I need to connect to a web server (I will use a Java web server) and from this server, it will communicate to the database server.
However, I am just wondering exactly how I would connect from an IPad app (that I will make in the future) to a Java App Server such as Glashfish. To do this, what kind of web app would I make (servlets?)? If I did, would I use the URL wrting method to transfer data?
I would want to use a http connection since I am using Glassfish.
Thanks
You can expose Restful API through the java web application; and access these api in your iOS app. There are many rest-client library for iOS now.
You can also write data to url connection directly, but it's tedious and complex.

Does iPad development work with interacting through Java code with Spring Framework using TomCat to host the web service on a server? How?

Here is the background of my situation:
I want to create an iPad application that interacts with a oracle SQL database. I have existing Java code from my Flex application that handles all the database requests, and modifications using the Spring Framework. The Flex Application ran as a web service through TomCat. Now I want to make that flex application into a mobile iPad version. I am having trouble figuring out what is the easiest way to use existing Java code and use it for the iPad because the iPad interacts using URL requests instead of direct with the Java.
My question is, can I use the existing Java code with the Spring framework to save time from coding all the back-end handling? Basically I want to access all the classes from my Java code by doing Requests from the iPad. Is this possible and will I need JSON or XML to interact between the iPad and the Java code?
Summary:
Can I use
iPad Objective-C <-----> Java (with spring framework) on TomCat Web Service to handle oracle SQL data handeling? If so, how and what technologies do I need? Will I need JSON or XML and how does that factor between the iPad and Java?
Thanks!
A good approach would be to design your app to communicate with RESTful services that return JSON. Once this is done your iPad app doesn't have to even know that the server code is written in Java.. it's just interacting over HTTP.
Here's a good tutorial on setting up your tomcat to host your RESTful services: http://www.vogella.com/articles/REST/article.html - I've used this for an app I'm developing. Spring isn't even necessary.
You could go XML, but JSON is just easier in my opinion. Here's a good blog outlining the good and bad of both sides. http://digitalbazaar.com/2010/11/22/json-vs-xml/
OK, I'm making the following presumptions.
Your flex application runs on a different machine from the Tomcat
server
Your flex application makes web service calls to the Tomcat server
So, the flex application doesn't know the underlying technology that provides the web services. It's just seeing/consuming the output
There's no reason why the iPad app can't do the same thing. There's no reason why it can't use the same web services that the Flex application uses. It could consume the same messages (Assuming it can handle the request/response format currently employed by the Flex application).
You can make changes if you like if you want to change the structure of the requests/responses between the clients. But the clients don't know (nor care) how the web services are implemented. They are just requesting and consuming info.

Java application vs web service vs web application

I am developing a multi-platform (Android, iPhone, Windows and Blacbberry) mobile application. The application needs to communicate with our server for several tasks, such as retrieving buddy lists etc. The server interacts with data that is stored in a MySQL database. I intend to code the server element in Java, however I am confused by all the different types. So far, I think I have narrowed it down to three options:
1) I code the application using Jetty to accept http posts. I post XML to the server, handle it, interact with the DB and post a XML response back. I would save the application as a jar and leave it running on my server.
2)I develop a Java web service. REST/JSON/SOAP?
3)I develop a Java web application.
Whilst there are many questions already out there asking what the differences is, I am struggling to find a clear explanation as to what is the best approach in which situation. I have previously used the first approach but am assuming the second approach is the better option, I'm just not sure what the advantage is.
your 1-3 options are all variants of a "Web application".
Jetty is a Java based http server/servlet container. If you want to communicate between client and server using http, you are using an http server (although not necessarily Jetty).
A Web Service is part of a web application that conforms to a standard around how clients communicate with the server, and how the server offers up information to the clients.
A web application is a Java application that makes it services available over http.
So if you want to have your clients communicate with a server, and store info in a db, you are using a web-application.
I would recommend going with option 2 as it is more lightweight and can be parsed directly in you're web application. XML got more overhead and must be translated, while you can just serialize objects directly to JSON from you're Java application and then parse them in javascript at frontend

Categories

Resources