communication between java application and javascript

I have an open source download manager written in javafx (desktop application) and I want to create browser extensions for all popular browsers which can send captured links to the desktop application. There are few ways to do this I have in my mind but cant figure out which will be the easiest and manageable way to do this. Here are few methods I am thinking of but It will be really nice if you can provide me some other better method(any code or link to article will be nice)

  1. Using sockets: Create a client in java that will listen to local hosted server created using (Dont know if its possible or easily implementable).
  2. Writing to local file system: I may write json files containing the data to local file system using javascript and then java application will read these json files and process data. (Actually there will be a loop that will check json file for changes).
  3. Create browser extension for all popular browser using browser specific apis for communication between native applications. Forexample chrome has api for this. But I dont want to do this because writing seprate code for each browser is time taking and managing all these plugins is also a problem I am looking for solution where I should write a single javascript code which I can literally copy paste in all plugins and it should work.

Just to be sure this is a desktop application not a java applet. And I am looking for some method that can send data from browser extension/plugin(javascript) to java application. The method should be browser independent.

Source: cross-browser

Leave a Reply