Network programming in Java (DCU specific)
DCU specific: Need to go through proxy
On Windows machines in the DCU campus (either within CA
or outside of CA),
HTTP requests have to go through
one of the DCU proxy servers.
Option 1: Insert in code
You can put something like this in your code before you make HTTP requests:
System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "proxyHost", "proxy.dcu.ie" );
System.getProperties().put( "proxyPort", "8080" );
|
Option 2: Use Java command-line arguments
Or you can leave your code alone
and set the proxy via the
$ java -D
command-line option:
$ java -DproxySet=true -DproxyHost=proxy.dcu.ie -DproxyPort=8080 prog
|
Write a batch (BAT) file
Writing a short
BAT file
to run java with the proxy command-line options
might be a better approach than embedding the proxy in your programs,
because then your programs will work when you run them on other machines
(e.g. at home).
Write the program dcujava.bat:
@echo off
java -DproxySet=true -DproxyHost=proxy.dcu.ie -DproxyPort=8080 %*
|
And then, when outside DCU:
When inside DCU:
And you don't have to change your code.
Non-Windows or non-DCU
You do not need to go through a proxy
on the Solaris UNIX servers in CA.
I don't know about Linux here.
Let me know.
You do not need to go through a proxy
on Windows on my home ISP,
but on some other ISPs you may need to change this to go through
their proxy.