Tuesday, July 17, 2007

java: setting proxy

when your java program needs to access the Internet using proxy, use this:
%java -Dhttp.proxyHost=proxyhost [-Dhttp.proxyPort=portNumber]

for example, I want to execute Reader.java

%javac Reader.java
%java -Dhttp.proxyHost=http://192.168.1.1 -Dhttp.proxyPort=8080 Reader


5 comments:

Unknown said...

and can I make exist program to work through proxy?

Daniel Adinugroho said...

Yes, this is how to run the existing program through a proxy.
I used to work in a university and our internet connection is through a proxy. My program cannot make a connection to internet since it is blocked on the proxy. The solution is to run my java program using this command.

Unknown said...

And if it is a web-based Java application?

Daniel Adinugroho said...
This comment has been removed by the author.
Daniel Adinugroho said...

No idea with your problem. Do you mean the Java EE application? Is that not the task of the sys admin to route it? if web based and using port 80, you should be able to manage it through your proxy server, I guess.