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
cmd.exe /C e:\\hosts\\start.bat
– Sosaecho 1
– Noticeable977472013
bytes because your first 4 bytes areCR
+LF
+C
+:
which gives us 0x0D 0A 43 3A
and in native order it becomes 0x3A 43 0A 0D
= 977472013 in decimal. The chrome team really needs to improve its example codes! – Noticeable