Skip to content

Commit

Permalink
修正无法运行Java的错误
Browse files Browse the repository at this point in the history
  • Loading branch information
EricTianC committed Feb 17, 2021
1 parent 78b1733 commit 0bfc0be
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions checkJRE.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ func checkJavaBin() bool {
case "macos":
matches, err := filepath.Glob("./jre/*/Contents/Home/bin/*")
if err == nil && len(matches) != 0 {
javaPath, _ = filepath.Split(matches[0])
javaPath = filepath.Dir(matches[0])
}
default:
matches, err := filepath.Glob("./jre/*/bin/*")
if err == nil && len(matches) != 0 {
javaPath, _ = filepath.Split(matches[0])
javaPath = filepath.Dir(matches[0])
}

}
Expand Down
5 changes: 3 additions & 2 deletions check_mcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"os"
"os/exec"
"path/filepath"
"strings"
)

Expand Down Expand Up @@ -48,7 +49,7 @@ func download_mcl() {

func first_run_mcl() {
args := append(MCL_BASE_ARG, os.Args...)
cmd := exec.Command(javaPath+JAVA, args...)
cmd := exec.Command(filepath.Join(javaPath, JAVA), args...)
cmd.Stdin = os.Stdin
stdout, err := cmd.StdoutPipe()
if err != nil {
Expand All @@ -62,7 +63,7 @@ func first_run_mcl() {
go wait_first_complete(stdout)
cmd.Wait()
args = append(MCL_BASE_ARG, "--update-package net.mamoe:mirai-api-http --channel stable --type plugin")
cmd = exec.Command(javaPath+JAVA, args...)
cmd = exec.Command(filepath.Join(javaPath, JAVA), args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"os"
"os/exec"
"path/filepath"
)

var javaPath string
Expand All @@ -12,7 +13,7 @@ func main() {
check_mcl()
args := []string{"-jar", "mcl.jar"}
args = append(args, os.Args...)
cmd := exec.Command(javaPath+JAVA, args...)
cmd := exec.Command(filepath.Join(javaPath, JAVA), args...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down

0 comments on commit 0bfc0be

Please sign in to comment.