I've been inspired by another question: Best Practice for Using Java System Properties
I'm currently looking for a complete list of Java system properties and possible values. I'm working on a simple class to simplify use of them (If you're interested, get the source and background info (my blog)). With this class, I try to provide the following:
- simple and consistent access to Java system properties (no String constants)
- full documentation of available properties and their possible values – within my IDE (i.e. auto-completion, inline Javadoc)
- fix inconsistencies in returned values and/or naming
- make sure that java.io.tmpdir exists – acutally that’s the main reason why I’m doing all this :)
To get full documentation and a complete list of available properties (even those where availability is heavily JVM-dependent), I'd like you to download the source, run it and post your results. I'll update the class accordingly and keep it available at the given location. Hopefully, it will ease live of some of you out there :)
Edit:
I'm not looking for standard properties as described by System.getProperties() or all properties that are available on my system. I'm trying to create a comprehensive list of system properties - even those that are vendor, jvm or version related - those that aren't guaranteed to exist and whose documentation is sparse or hard to find. Properties like
- sun.desktop (Linux only, e.g. "gnome"),
- awt.toolkit (Mac only, e.g. apple.awt.CToolkit)
- sun.cpu.endian (Sun JVMs only)
- ...
I'd love to get others to run my code and post their results in order to compile a comprehensive list (with extensive documentation of properties and their possible values) in the form of a Java enum that's easy to use e.g.:
String file = SystemProperty.JAVA_IO_TMPDIR + "file.txt";
instead of
String tmp = System.getProperty("java.io.tmpdir");
if (!tmp.endsWith(File.separator)
tmp += File.separator;
new File(tmp).mkdirs(); // make sure tmp exists
String file = tmp + "file.txt";
So please run that code and post your findings. Here is a simple script to get you started:
#!/bin/bash
# download and run
# you should really look at the code first, as you can't be sure
# that I'm a trustworthy guy ;)
wget -N http://techblog.molindo.at/files/SystemProperty.java
javac SystemProperty.java
java SystemProperty
(I know this isn't a real question but rather a crowd sourcing thing. I hope nobody minds)
Bounty:
As there is no correct answer to this question, the bounty will be awarded to the person who discovers most new system properties. As a hint: testing non-standard JVMs (J2ME, Android, GCJ, OpenJDK, Apache Harmony, ...) and common languages on top of the JVM (Groovy, Scala, JRuby, ..) should be especially yielding.
Current leaders:
- rsp 19 discovered properties
- Boris 14 discovered properties
- Joa Ebert 8 discovered properties
- Suraj Chandran 1 discovered property
Btw, I'm planning to release the final result as a Maven artifact and upload it to the central repository as soon as I have enough input.
UPDATE: Public Repository, finally
SystemProperty.java is now available on GitHub, as part of the molindo-utils project. molindo-utils is currently available as 1.0-SNAPSHOT through Sonatype's OSS repository. As soon as it's ready for release, it will be synchronized to Maven central as well.
<repositories>
<repository>
<id>oss.sonatype.org</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>at.molindo</groupId>
<artifactId>molindo-utils</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
http.proxyHost
andhttp.proxyPort
? – Aduwa