3

I have developed a Chrome extension and it captures some data in a webpage. My ultimate goal is to pass this final result to my Java Application. I have following few options in my mind, but I was not able to find any resources for them yet.

  1. Access the localStorage externally.

  2. Run Chrome browser through the Java app, So I guess we have the control of its data.

  3. If no API found, write the result to a file and access it from the Java App.

Is there any API to achieve any of the first 2 options? Or any other interface other than the file system?

I checked with berkelium and The Chromium Embedded Framework. But they are just chrome wrappers, and we cannot run a chrome instance from it.

Edit

For the 2nd option I tried with Selenium Webdriver, but I think it hasn't any method to access the localStorage.

Tharaka Deshan
  • 1,349
  • 3
  • 15
  • 30

2 Answers2

3

It sounds like you are looking for Native Messaging, which allows communication between a Chrome Extension and a native application (e.g. a Java Desktop Application).

There are plenty of question here on SO regarding the implementation of Native Messaging and there is, also, the "official" example.


I suggest the above solution, but if your application will heavily interact with the extension (and you feel like reverse engineering) there is the open-source **[NetBeans Connector Chrome Extension][3]**, which uses a different approach (Sockets or WebSockets - I am not sure). Take a look at **[this answer][4]** for info on how to get at the sources.
koppor
  • 19,079
  • 15
  • 119
  • 161
gkalpak
  • 47,844
  • 8
  • 105
  • 118
0

Is there a limitation preventing you from exposing a REST API with your java application?

Gruff McGruff
  • 280
  • 2
  • 9