I'm trying to trigger java command line application as a sub process from golang. For some reason it failed and actually I do not get java APP interface when I start it from GO. It wait for few sec and terminate with error code "can not connect ... " Here is a code I tried to use:
package main
import (
"fmt"
"os/exec"
)
func main() {
start_java_app_test()
}
func start_java_app_test() {
cmd_prep := "java -Xmx2g -jar test_app.jar"
cmd_output, err := exec.Command("bash", "-c", cmd_prep).Output()
if err != nil {
fmt.Println(err)
}
fmt.Println(vba_ssh_cmd_output)
}
If we try just to use --> cmd_prep := "java -version"
<-- it will fail again. It should give me output like << snip >> $ java -version java version "1.8.0_65" Java(TM) SE Runtime Environment (build 1.8.0_65-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode) << /snip >>
The normal syntax like --> cmd_prep := "ls -l"
<-- works fine. Any clue ? What might be the reason here ? Thanks in advance, .C
It works very well with 'CombinedOutput' :)
$ go run TestCombinedOutput.go
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
Thanks a lot.
Cheers,
.C