我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

exec.Command调用java cli

How can I make the exec.Command command call a command from another file?

func main() {
    fmt.Println("Iniciando...")
    command := exec.Command("java -version")
    command.Dir = "."
    output, err := command.Output()
    if err != nil {
        fmt.Println("Erro: ", err)
    }

    fmt.Printf("%s", output)

}

Erro: exec: "java -version": executable file not found in $PATH

Each argument needs to be in its own separate string. Try exec.Command("java", "-version")

近期文章

  • 在TestMain中使用testing.T
  • 如何实现通用切片追加器?
  • 工具存放在哪里?
  • Go中Urdu文本的编码[关闭]
  • 进行单元测试未找到所需文件
  • 如何使用godoc在GO中创建文档?
  • 初始化期间出现“权限被拒绝”错误[关闭]
  • 使用os.exec执行'su'返回错误
  • 更新1.1麻烦,无法在文件夹中运行Go文件和JSON文件
  • 如何在不同的包中测试未导出的struct字段?
  • GO API安装失败“ evq /色度”
  • 可以在Go-SDK上删除s3前缀吗?
  • 当作为参数传递给单独包中的函数时,Struct不是类型
  • 通过接口获取结构的值
  • 如何在中间件中获取请求主体
  • 使用矩阵接口作为参数的Go函数
  • 将提供的CLI用于Go库
  • [] * Users和* [] Users golang结构之间的区别
  • 改变CAS+LDAP架构体系
  • 传递给另一个函数时,为什么需要指向Go bytes.Buffer的指针?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华