How do I set the proxy to be used by the JVM
From the Java documentation (not the javadoc API):
http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html
Set the JVM flags http.proxyHost
and http.proxyPort
when starting your JVM on the command line.
This is usually done in a shell script (in Unix) or bat file (in Windows). Here's the example with the Unix shell script:
JAVA_FLAGS=-Dhttp.proxyHost=10.0.0.100 -Dhttp.proxyPort=8800
java ${JAVA_FLAGS} ...
When using containers such as JBoss or WebLogic, my solution is to edit the start-up scripts supplied by the vendor.
Many developers are familiar with the Java API (javadocs), but many times the rest of the documentation is overlooked. It contains a lot of interesting information: http://download.oracle.com/javase/6/docs/technotes/guides/
Update : If you do not want to use proxy to resolve some local/intranet hosts, check out the comment from @Tomalak:
Also don't forget the http.nonProxyHosts property!
-Dhttp.nonProxyHosts="localhost|127.0.0.1|10.*.*.*|*.example.com|etc"
Setting system-wide/global proxy in java
The solution was different for each platform, I currently only implemented the proxy settings on Windows and OSX.
- Modify the preferences.plist file on OSX, this is the file located at
/Library/Preferences/SystemConfiguration/preferences.plist
- Modify the registry on Windows, editing the following path
Software\Microsoft\Windows\CurrentVersion\Internet Settings
Set http_proxy environment variable with domain user and pass in windows
It's common for hosts to not respond to ICMP echo, so ping will time out, it doesn't mean anything any more (it used to back in the day when everything responded).
Proxy credentials = Domain credentials? Maybe. Depends on whether the proxy is configured to use your domain accounts or not. Since it's TMG, I'd say that is very likely.
http_proxy variable for what? Browsers don't use environment variables for proxy config.
That error 407 is an auth challenge from the proxy. You won't get any further until you start providing credentials that the proxy will accept.
Related Topics
Verify If a Process Is Running Using Its Pid in Java
Low Java Single Process Thread Limit in Red Hat Linux
Can't Start Cassandra (Single-Node Cluster on Centos7)
Java Getlocalhost() Unknownhostexception /Etc/Hosts File Differs Linux API
Java.Lang.Runtime Exception "Cannot Run Program"
Serial Port Identification with Java on Ubuntu
Rjava Install Error "Java_Home Cannot Be Determined from the Registry"
How to Support Both Ipv4 & Ipv6 on Java
How to Create Native Binaries for Your Java App
Connect to SQL Server from Linux via Jdbc Using Integratedsecurity (Windows Authentication)
Arval SQLexception: Fatal: Sorry, Too Many Clients Already in Postgres
Cross-Platform Way to Open a File Using Java 1.5
How to Use Chef to Update-Alternatives for Java Using Execute
Why Stringbuilder Stops Adding Elements After Using the Null Character
Eclipse Release Heap Back to System
Java -Xbootclass Path Is No Longer a Supported Option
When Should We Use Intern Method of String on String Literals