dex*_*ter 5 google-chrome google-chrome-app chrome-native-messaging
我用Java编写了一个chrome应用程序和一个本机消息传递主机.该组合在Linux上运行良好.但是,当我尝试将组合移植到Windows时,无法建立通信.包含主机的jar与linux变体完全相同.我使用以下脚本(start.bat)来启动Java主机:
@echo off
java -jar "%~dp0theHost.jar"
Run Code Online (Sandbox Code Playgroud)
json清单如下:
{
"name": "com.service.host",
"description": "Native messaging host",
"path": "start.bat",
"type": "stdio",
"allowed_origins": [
"chrome-extension://--the ID--/"
]
}
Run Code Online (Sandbox Code Playgroud)
我已将HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.service.host配置到路径e:\ hosts\com.service.host.json,service.bat文件与jar(theHost.jar)一起也是在e:\ hosts \目录中.尝试启动通信时,我收到错误:与本机消息传递主机通信时出错.我还尝试将清单中的路径更改为:e:\\hosts\\start.bat
但结果/错误是相同的.当我在cmd窗口中手动启动bat文件时,主机会根据我的判断正确初始化并等待来自Chrome应用程序的消息.另外,当我添加该行时:
copy NUL empty.txt
Run Code Online (Sandbox Code Playgroud)
在"java-jar ..."行之前,当调用bat时创建一个空文件,当手动启动bat时创建空文件,而chrome应用程序"调用"时不创建空文件.任何帮助将不胜感激.
版本:Windows 7,Java 7u55,Chrome 34.0.1847.116 m