What is the difference between using javac and javax.tools.JavaCompiler?

javac (as “java compiler”) is an executable, which could be theoretically even a platform-dependent executable or a script. This is called to compile a .java to a .class. On windows is its name javac.exe, and it is normally somewhere below C:\Program Files*\jdk*\bin. This compiler was developed in java as well. That means, if we start …

Read more

Setting JVM/JRE to use Windows Proxy Automatically

It is possible to detect the proxy using the ProxySelector class and assign the system proxy by assigning environment variables with the setProperty method of the System class: System.setProperty(“java.net.useSystemProxies”, “true”); System.out.println(“detecting proxies”); List l = null; try { l = ProxySelector.getDefault().select(new URI(“http://foo/bar”)); } catch (URISyntaxException e) { e.printStackTrace(); } if (l != null) { for …

Read more

Get a list of all classes loaded in the JVM

It’s not a programmatic solution but you can run java -verbose:class …. and the JVM will dump out what it’s loading, and from where. [Opened /usr/java/j2sdk1.4.1/jre/lib/rt.jar] [Opened /usr/java/j2sdk1.4.1/jre/lib/sunrsasign.jar] [Opened /usr/java/j2sdk1.4.1/jre/lib/jsse.jar] [Opened /usr/java/j2sdk1.4.1/jre/lib/jce.jar] [Opened /usr/java/j2sdk1.4.1/jre/lib/charsets.jar] [Loaded java.lang.Object from /usr/java/j2sdk1.4.1/jre/lib/rt.jar] [Loaded java.io.Serializable from /usr/java/j2sdk1.4.1/jre/lib/rt.jar] [Loaded java.lang.Comparable from /usr/java/j2sdk1.4.1/jre/lib/rt.jar] [Loaded java.lang.CharSequence from /usr/java/j2sdk1.4.1/jre/lib/rt.jar] [Loaded java.lang.String from /usr/java/j2sdk1.4.1/jre/lib/rt.jar] See …

Read more