Re: [go-nuts] How to run a java file using go script.

2022-08-04 Thread Kurtis Rader
On Thu, Aug 4, 2022 at 12:44 AM TECHAX wrote: > Thank you so much, I am able to add java path. I also need to add some > other path as well, so Can I do like this: > > > > > > > *os.Setenv("PATH","/home/sdk/jdk-11.0.16/bin:/home/temp/jtreg/bin:$PATH")cmd,err:=exec.Command("java","-version").Combi

Re: [go-nuts] How to run a java file using go script.

2022-08-04 Thread 'Thomas Faughnan' via golang-nuts
On Thu Aug 4, 2022 at 12:24 AM EDT, TECHAX wrote: > I tried the following one but still, it's not working. > > *os.Setenv("PATH","/home/sdk/jdk-11.0.16/bin")* > *cmd,_:=exec.Command("java","-version").Output()* > *fmt.Println(string(cmd))* > > Since the path is set, so it should display the java ve

Re: [go-nuts] How to run a java file using go script.

2022-08-04 Thread Peter Galbavy
When you use cmd, err := exec.Command(...) you then set-up it's environment before execution by setting cmd.Env: cmd.Env = append(os.Environ(), `PATH="..."`) and only then run the command: out, err := cmd.Output() if err ... { ... } fmt.Println("output:", out) The above mostly from

Re: [go-nuts] How to run a java file using go script.

2022-08-04 Thread TECHAX
Thank you so much, I am able to add java path. I also need to add some other path as well, so Can I do like this: *os.Setenv("PATH","/home/sdk/jdk-11.0.16/bin:/home/temp/jtreg/bin:$PATH")cmd,err:=exec.Command("java","-version").CombinedOutput()if err != nil { fmt.Println(err)}fmt.Printl

Re: [go-nuts] How to run a java file using go script.

2022-08-03 Thread Jan Mercl
On Thu, Aug 4, 2022 at 6:24 AM TECHAX wrote: > I tried the following one but still, it's not working. > > os.Setenv("PATH","/home/sdk/jdk-11.0.16/bin") > cmd,_:=exec.Command("java","-version").Output() > fmt.Println(string(cmd)) > > Since the path is set, so it should display the java version, ri

Re: [go-nuts] How to run a java file using go script.

2022-08-03 Thread TECHAX
I tried the following one but still, it's not working. *os.Setenv("PATH","/home/sdk/jdk-11.0.16/bin")* *cmd,_:=exec.Command("java","-version").Output()* *fmt.Println(string(cmd))* Since the path is set, so it should display the java version, right? On Thu, Aug 4, 2022 at 1:45 AM Kurtis Rader wr

Re: [go-nuts] How to run a java file using go script.

2022-08-03 Thread Kurtis Rader
On Wed, Aug 3, 2022 at 11:38 AM TECHAX wrote: > I tried this for setting Java, but not working. > > CMD:= exec.Command("bash","-c","export PATH=/home/user/jdk8/bin") > > Can you please help me with this? > That statement starts a new bash process which modifies its environment and exits, thus th

Re: [go-nuts] How to run a java file using go script.

2022-08-03 Thread TECHAX
I tried this for setting Java, but not working. CMD:= exec.Command("bash","-c","export PATH=/home/user/jdk8/bin") Can you please help me with this? On Wed, 3 Aug, 2022, 7:48 pm Eli Bendersky, wrote: > You should be able to use the os/exec package (https://pkg.go.dev/os/exec) > to invoke exter

Re: [go-nuts] How to run a java file using go script.

2022-08-03 Thread Eli Bendersky
You should be able to use the os/exec package (https://pkg.go.dev/os/exec) to invoke external programs from Go. On Wed, Aug 3, 2022 at 5:45 AM PK wrote: > Hi everyone, > I am new to golang. I was writing a script, with which I want to run a > java program. > Can anyone please let me know how to

[go-nuts] How to run a java file using go script.

2022-08-03 Thread PK
Hi everyone, I am new to golang. I was writing a script, with which I want to run a java program. Can anyone please let me know how to run java file using go scripts. Thanks -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from t