user1778203 February 2016

executing jar from golanguage program in windows

'package main

import (
    "fmt"
    "log"
    "os/exec"
    "strings"
)

func main() {
    //var java = "\\jrex64\\bin\\java.exe"
    var java ="jre/lib/java.exe"

    var path = []string{
        "jrex64\\lib\\rt.jar",
        "jrex64\\lib\\jfxrt.jar",
        "jrex64\\lib\\resources.jar",
        "jrex64\\lib\\ext\\sunjce_provider.jar",
        "jrex64\\lib\\ext\\zipfs.jar",
        "jrex64\\lib\\ext\\sunmscapi.jar",
        "jrex64\\lib\\ext\\sunec.jar",
        "jrex64\\lib\\ext\\dnsns.jar",
        "jrex64\\lib\\ext\\access-bridge-64.jar",
        "jrex64\\lib\\security\\local_policy.jar",
        "jrex64\\lib\\jce.jar",
        "jrex64\\lib\\jfr.jar",
        "jrex64\\lib\\jsse.jar",
        "jrex64\\lib\\charsets.jar",
        "jrex64\\lib\\",
    }

    var pathflag  string = "-Xbootclasspath:" + strings.Join(path, ";")
    cmd := exec.Command(java, "-verbose", pathflag, "-cp Ganesha_lib\\*", "-jar Ganesha.jar")
    err := cmd.Run()

    if err != nil {
        fmt.Println("an error occurred.\n")
        log.Fatal(err)
    }

}

I want to call a jar file from go lang program in windows on window my java is installed in programfiles how do i set up the path for java variable and path variable in windows

Answers


Melis February 2016

Well, depending on which version you have of windows there is slightly different methods of setting your PATH and ENVIROMENT variables.

Here you will find guides for most windows versions.

Post Status

Asked in February 2016
Viewed 1,810 times
Voted 4
Answered 1 times

Search




Leave an answer