如何将属性传递给Powershell的jar? [英] How to pass Properties to jar from Powershell?

查看:147
本文介绍了如何将属性传递给Powershell的jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Powershell-1.0作为命令行需求,而不是cmd.exe。
不幸的是,使用java时仍有一些注意事项。
我需要将一个属性传递给jar,就像那样:

I've been using Powershell-1.0 for command line needs for a while, instead of cmd.exe. Unfortunately, there are still some caveats when using java. I need to pass a property to a jar, like that:

java -jar -Duser.language=en any.jar

此行在cmd.exe中工作正常,但在Powershell中没有,因为它搜索另一行jar:
无法访问jarfile user.language = zh_CN

This line works fine in cmd.exe, but not in Powershell as it searches for another jar: Unable to access jarfile user.language=en

使用引号无济于事。

它在Powershell-1.0中是否可行,或者我是否错过了java中的内容?

Is it doable in Powershell-1.0, or do I miss something in java?

提前致谢,

问候,

jgran

推荐答案

看看我的回答这个问题。请注意如何使用echoargs.exe来诊断这些问题。最有可能修复的方法是引用参数,例如:

Take a look at my answer to this question. Note how you can use echoargs.exe to diagnose these sort of problems. Most likely the fix would be to quote the parameter e.g.:

java -jar "-Duser.language=en" any.jar

您可以使用echoargs测试它(来自 PowerShell社区扩展):

You can test that using echoargs (from PowerShell Community Extensions):

echoargs -jar "-Duser.language=en" any.jar
Arg 0 is <-jar>
Arg 1 is <-Duser.language=en>
Arg 2 is <any.jar>

这篇关于如何将属性传递给Powershell的jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆