I've got an example Java application that requires an HTTP Proxy to be specified in some environments.
When I try running this using the argument as suggested on the Oracle website in CMD (Command Prompt) it works fine.
E:\>java -Dhttp.proxyHost=http://proxy.example.com -jar myJAR.jar
System properties...
[...]
http.proxyHost=http://proxy.example.com
You can see that the application has been run, and when listing the system properties it's correctly received the http.proxyHost
property.
However, when I run this from Powershell, I get the following:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS E:\> java -Dhttp.proxyHost=http://proxy.example.com -jar myJAR.jar
Error: Could not find or load main class .proxyHost=http:..proxy.example.com
Here it appears some kind of breaking has occurred around the first "." and from then on it's treated the rest as another argument.
If the argument is quoted - e.g. -D"http.proxyHost"=http://proxy.example.com
- then it works fine in Powershell.
Can anyone explain this behavior, please?