4

On my Linux box using an older javaws I can pass a system property to Java via javaws with something like

javaws -J-Dsome.key=some.value http://some.jnlp

However it seems on my Mac using a newer version of javaws this does not work. The "-Dsome.key=some.value" is not passed to the java process (looking at the java process launched by javaws, the -D option is simply not there). However, other Java options are passed without issue, eg.

javaws -J-verbose:gc http://some.jnlp

works fine on both Linux and Mac (I can see the -verbose:gc option fine in the java process launched by javaws).

Does anyone have any ideas? Is it a security setting? Is it a bug in javaws on Mac?

Graeme Moss
  • 7,995
  • 4
  • 29
  • 42

1 Answers1

5

You can do that via Java Control Panel. Goto Java Control Panel > Java > View..

Then type -Dsome.key=some.value under "Runtime Parameters".

Edit: Alternatively you can make sure that your parameters start with "jnlp." such as jnlp.some.key. The reason for this is that with new security restrictions in java you're not allowed to pass parameters unless you either sign you jnlp file (done through jar file manifest) or start your parameter with "jnlp." or "javaws."

Saeid Nourian
  • 1,606
  • 15
  • 32
  • I want to programmatically change the system property via the command line as I want to supply different values for different invocations of javaws. – Graeme Moss Feb 10 '15 at 08:19
  • It could be security restriction as you said. I know that inside jnlp you can't pass properties unless the propery starts with jnlp. (source: http://stackoverflow.com/questions/19400725/with-java-update-7-45-the-system-properties-no-more-set-from-jnlp-tag-property). Maybe this restriction is in addition to that. – Saeid Nourian Feb 10 '15 at 16:40
  • That worked! Changing my key to jnlp.some.key allowed me to set it via the command line. Please change your answer to match and I will mark it correct. – Graeme Moss Feb 12 '15 at 08:42
  • I edited the question to better reflect the issue. It's not about mac vs Linux but old vs new version of javaws. – Graeme Moss Feb 12 '15 at 19:25