Skip to content

Commit 4517864

Browse files
author
Stefan Bethke
committed
More or less version 1.0.
1 parent f9d1ae3 commit 4517864

File tree

3 files changed

+78
-3
lines changed

3 files changed

+78
-3
lines changed

README.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,46 @@
1-
javaproxycheck
2-
==============
1+
# Java Proxy Check
32

4-
Simple Java command line client to debug the Java HTTP proxy settings in effect.
3+
Have you ever had the (mis-)fortune to have to run Java code behind an
4+
HTTP proxy? Or worse, having to have to go through a proxy for certain
5+
URLs, but not for others? Have you fought the syntax for defining proxy
6+
exceptions that differ between OSes and Java?
7+
8+
This tool won't help you fix your config, but it helps you to test things
9+
out quickly.
10+
11+
12+
## Building
13+
14+
The project uses gradle, a simple `gradle build` should create the jar in
15+
`build/libs/javaproxycheck.jar`.
16+
17+
18+
## Download
19+
20+
A ready-to-run binary compiled with Java 1.7.0_51 is available here:
21+
http://www.lassitu.de/software/javaproxycheck/javaproxycheck.jar
22+
23+
24+
## Usage
25+
26+
proxycheck.jar can be run like this:
27+
```
28+
$ java -jar proxycheck.jar http://www.example.com https://secure.example.com
29+
```
30+
31+
The output will list the URLs and the selection the system ProxySelector.select() method
32+
returns. You can interactively try out the various system properties like so:
33+
```
34+
$ java -Dhttps.proxyHost=proxy.example.com -Dhttps.proxyPort=3128 -jar build/libs/javaproxycheck.jar http://www.example.com https://secure.example.com
35+
http://www.example.com [DIRECT]
36+
https://secure.example.com [HTTP @ proxy.example.com:3128]
37+
```
38+
39+
40+
## Java Proxy Settings
41+
42+
Java has built-in support for Windows, Mac OS X, and Gnome system proxy settings; on other
43+
platforms, you have to run Java programs with appropriate system properties specifying
44+
which proxies to use when. See the following documentation:
45+
46+
http://download.java.net/jdk7/archive/b123/docs/api/java/net/doc-files/net-properties.html#Proxies

build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
apply plugin: 'java'
3+
4+
repositories {
5+
mavenCentral()
6+
}
7+
8+
dependencies {
9+
}
10+
11+
manifest.mainAttributes("Main-Class" : "de.lassitu.JavaProxyCheck")

src/main/java/JavaProxyCheck.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package de.lassitu;
2+
3+
import java.net.ProxySelector;
4+
import java.net.URI;
5+
import java.net.URISyntaxException;
6+
7+
class JavaProxyCheck {
8+
public static void main(String args[]) {
9+
ProxySelector s = ProxySelector.getDefault();
10+
11+
if (args.length == 0) {
12+
System.err.println("usage: java -jar JavaProxyCheck.jar http://www.example.com/");
13+
}
14+
for (String a : args) {
15+
try {
16+
System.out.printf("%-40.40s %s\n", a, s.select(new URI(a)));
17+
} catch (URISyntaxException | IllegalArgumentException e) {
18+
System.out.printf("%-40.40s Invalid URI: %s\n", a, e.getMessage());
19+
}
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)