简体   繁体   中英

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:

$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:

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

I have tried:

  1. The ssl options with/without quotes around the value
  2. Actually setting the JAVA_OPTS environment variable, until I read somewhere else that the JVM doesn't ever read that variable.
  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:

Why does PowerShell split arguments containing hyphens and periods?

Windows is (for some reason) splitting the parameters in half.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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