简体   繁体   English

使用Java_OPTS启动Java

[英]Launching Java With Java_OPTS

This should be a pretty simple question, I can't believe I wasn't able to find anything from googling. 这应该是一个非常简单的问题,我无法相信我无法从谷歌搜索中找到任何东西。

I'm using powershell and I'm trying to run a java app from command line: 我正在使用Powershell,并且尝试从命令行运行Java应用程序:

$memory = "-Xms128m -Xmx1028m -XX:MaxPermSize=512m"
$ssl = "-Djavax.rmi.ssl.client.enabledProtocols=`"TLSv1`" -Djavax.rmi.ssl.client.enabledCipherSuites=`"_removed_`" -Djavax.net.ssl.trustStorePassword=`"_removed_`" -Djavax.net.ssl.trustStore=`"_removed_`" -Djavax.net.ssl.keyStorePassword=`"_removed_`" -Djavax.net.ssl.keyStore=`"_removed_`" -Djava.endorsed.dirs=`"$($ddmsLoc)tomcat6\endorsed`""

$classpath = getClasspath "manager" $null
$java_opts = "$($memory) $($ssl) -Djavax.net.debug=all"
$cmd = "$($java) $($java_opts) -cp `"$($classpath)`" dss.vector.solutions.manager.server.ServerStatus -g"

Invoke-Expression $cmd

But for some reason it thinks my JAVA_OPTS parameters are the name of the java class I'm running: 但是出于某种原因,它认为我的JAVA_OPTS参数是我正在运行的Java类的名称:

Caused by: java.lang.ClassNotFoundException: .rmi.ssl.client.enabledProtocols=TLSv1

I have tried: 我努力了:

  1. The ssl options with/without quotes around the value 带有/不带引号的ssl选项
  2. Actually setting the JAVA_OPTS environment variable, until I read somewhere else that the JVM doesn't ever read that variable. 实际设置JAVA_OPTS环境变量,直到我读到其他地方JVM从未读过该变量为止。
  3. wrapping them in more quotes 用更多引号将它们包裹起来

I'm kind of at a loss here. 我有点不知所措。

Etan Reisner posted a comment that helped me to solve it: 伊坦·赖斯纳(Etan Reisner)发表了一条评论,帮助我解决了这一问题:

Why does PowerShell split arguments containing hyphens and periods? 为什么PowerShell会拆分包含连字符和句点的参数?

Windows is (for some reason) splitting the parameters in half. Windows正在(出于某种原因)将参数分成两半。

echo -Dmy.param=value

returns: 收益:

-Dmy
.param=value

If the parameter is wrapped in quotes, like: 如果参数用引号引起来,例如:

echo "-Dmy.param=value"

Then it works just fine. 然后就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM