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
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
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
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
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
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
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
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
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
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
10 matches
Mail list logo