Connecting Java and Chrome extension via native messaging

27 Views Asked by At

I'm trying to connect Chrome extension to Java application on MacOS. Using manifest version 2 for testing purposes. My question is this - what should I specify as path inside host manifest file?

host_manifest

{
    "name": "...",
    "description": "...",
    "path": "...", <---- talking about this
    "type": "stdio",
    "allowed_origins": [
        "chrome-extension://.../"
    ]   
}    

Since Java is not a native application I think I should specify something like bash file that runs jar file with Java.

start.bash

java -jar "native-messaging-test-1.0-SNAPSHOT-jar-with-dependencies.jar"

Then I specify like this

host_manifest

{
    "name": "...",
    "description": "...",
    "path": "/bunch/of/directories/start.bash", <---- changed to location of start.bash
    "type": "stdio",
    "allowed_origins": [
        "chrome-extension://.../"
    ]   
}    

But unfortunately it doesn't work saying: Failed to start native messaging host.. I think my mistake is made here.

1

There are 1 best solutions below

0
guest271314 On

Use .sh extension for the Bash file. Make sure the .sh file is executable and write the absolute path to the .sh file in "path" value in the manifest.