从Java中接收来自Chrome的本地消息 [英] Receiving native messages from Chrome in Java
问题描述
我试图在chrome扩展和Java程序之间进行本地消息传递。
经过一番努力,我现在可以打开我的Java程序:
I am trying to get native messaging between a chrome extension and a Java program to work. After some struggling I now can open my Java program with:
var port = chrome.extension.connectNative('fbehost');
port.postMessage({ text: "Hello, my_application" });
但我不知道如何阅读从我的扩展程序发送的消息。我创建了一个使用textarea打开简单JFrame的程序。正如它在文档中所说的本地消息传递与stdin和stdout进行通信,我试图通过以下方式获取消息:
But I don't know how I can read the message send from my extension. I created a program which opens a simple JFrame with a textarea. As it says in the documentation that native messaging communicates with stdin and stdout, I tried to get the message with:
while(true) {
try {
input=br.readLine();
tf.setAreaText(input);
} catch(Exception e) {
}
}
还试过:
Also tried it with:
System.in.read()
该jar被执行,但textarea保持空白。我无法在互联网上找到任何有关如何使用Java获取数据的信息。您可以帮助我吗?
The jar gets executed but the textarea stays empty. I can't find any information on the internet how to get the data in Java. Can you help me?
推荐答案
我最近无法使用任何本机讯息在Google Chrome中工作。我记得在某个地方看到,一个半最近的更新似乎阻止了Java和Chrome之间的本地消息传递的兼容性。祝你好运。
I haven't been able to get any native messaging to work in Google Chrome recently. I remember reading somewhere that a semi-recent update appeared to prevent compatibility between Java and Chrome for native messaging. Best of luck.
这篇关于从Java中接收来自Chrome的本地消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!