I have written a chrome app and a native messaging host in Java. The combo works fine on linux. However when I try to port the combo to windows the communication can not be established. The jar where the host is contained is exactly the same as the linux variant. I am using the following script (start.bat) to start the Java host:
@echo off
java -jar "%~dp0theHost.jar"
The json manifest is as follows:
{
"name": "com.service.host",
"description": "Native messaging host",
"path": "start.bat",
"type": "stdio",
"allowed_origins": [
"chrome-extension://--the ID--/"
]
}
I have configured the HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.service.host to the path e:\hosts\com.service.host.json
the service.bat file together with the jar (theHost.jar) is also in the e:\hosts\ directory.
When trying to start the communication I get the error: Error when communicating with the native messaging host.
I also tried to change the path in the manifest to: e:\\hosts\\start.bat
but the result/error is the same.
When I start the bat file manually in the cmd window the host initializes properly as far as I can tell and waits for the message from the Chrome app. Also, when I added the line:
copy NUL empty.txt
before the "java - jar..." line to create an empty file when the bat is invoked, the empty file is created when the bat is started manually and is not created when "invoked" by the chrome app. Any help would be greatly appreciated.
Versions: Windows 7, Java 7u55, Chrome 34.0.1847.116 m
To debug errors that do not give meaningful messages in JS context, you can try using Chrome logging; this can give more information (which helped in your case).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With