Hello,
How can we set proxy configuration using Java? Proxy setting is not mentioned in the TRKD API developers guide. Is there any code snippet that can be shared to show the mechanism?
Thanks
Thisarticle describes configuration of a proxy server for Java.
Inorder to configure a proxy server for a Java application you should set up thefollowing system properties (seearticleon Oracle site for additionaldetails):
For HTTP traffic:
http.proxyHost(default: <none>)
The host name, oraddress, of the proxy server
http.proxyPort(default: 80)
The port number of theproxy server.
http.nonProxyHosts(default: localhost|127.*|[::1])
Indicates the hoststhat should be accessed without going through the proxy. Typically this definesinternal hosts. The value of this property is a list of hosts, separated by the'|' character. In addition the wildcard character '*' can be used for patternmatching. For example -Dhttp.nonProxyHosts=”*.foo.com|localhost” will indicatethat every hosts in the foo.com domain and the localhost should be accesseddirectly even if a proxy server is specified.
For HTTPS traffic:
https.proxyHost(default: <none>)
https.proxyPort(default: 443)
Note:TheHTTPS protocol handler will use the same nonProxyHosts property as the HTTPprotocol.
You can use two mainapproaches how to set environment variables in Java applications (the followingexamples assume your proxy server host is "localhost" and port is 8888):
Commandline option when invoking the VM:
jre-Dhttp.proxyHost=localhost -Dhttp.proxyPort=8080 myApp
jre-Dhttps.proxyHost=localhost -Dhttps.proxyPort=8080 myApp
Using theSystem.setProperty(String,String)method, assuming thatyou have permission to do so:
System.setProperty("http.proxySet","true");
System.setProperty("http.proxyHost","localhost");
System.setProperty("http.proxyPort","8888");
System.setProperty("https.proxySet","true");
System.setProperty("https.proxyHost","localhost");
System.setProperty("https.proxyPort","8888");
@Shaikh, Thanks for the reply. With reference to Chapter 53 "Building a java client" in the TRKD API guide, how/where does the above fit in?
@Shaikh, Can you please get back on the my previous question "
With reference to Chapter 53 "Building a java client" in the TRKD API guide, how/where does your solution fit in?
@NWM reviewing portal questions and I see your follow up was not answered. Do you still need help on that point? The response from Waseem indicated both a command line and code approach to setting the java proxy.