Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Browser and Java Message Passing

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.

like image 770
Tharaka Deshan Avatar asked Aug 07 '26 04:08

Tharaka Deshan


1 Answers

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.
like image 176
gkalpak Avatar answered Aug 08 '26 17:08

gkalpak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!