Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crowdsourcing a Complete list of Common Java System Properties and Known Values

Tags:

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:

  1. rsp 19 discovered properties
  2. Boris 14 discovered properties
  3. Joa Ebert 8 discovered properties
  4. 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> 
like image 979
sfussenegger Avatar asked Nov 26 '09 11:11

sfussenegger


People also ask

What are the system properties in Java?

System properties include information about the current user, the current version of the Java runtime, and the character used to separate components of a file path name. Character that separates components of a file path.

How to get system properties in Java?

To get a specific system property you can use System. getProperty(String key) or System. getProperty(String key, String def) . Environment variables are set in the OS, e.g. in Linux export HOME=/Users/myusername or on Windows SET WINDIR=C:\Windows etc, and, unlike properties, may not be set at runtime.

How does system getProperty work in Java?

The getProperty(String key) method in Java is used to returns the system property denoted by the specified key passed as its argument.It is a method of the java. lang. System Class. where key is the name of the System property.

What is a system properties?

System Properties is a section of Microsoft Windows for editing operating system settings, including hardware settings, connectivity, user profiles, security settings, and the computer name. The image below shows an example of how the system properties window looks in Windows 10.


1 Answers

From the javadoc of System.getProperties, only these are guaranteed:

java.version - Java Runtime Environment version  java.vendor - Java Runtime Environment vendor  java.vendor.url - Java vendor URL  java.home Java - installation directory  java.vm.specification.version - Java Virtual Machine specification version  java.vm.specification.vendor - Java Virtual Machine specification vendor  java.vm.specification.name - Java Virtual Machine specification name  java.vm.version - Java Virtual Machine implementation version  java.vm.vendor - Java Virtual Machine implementation vendor  java.vm.name - Java Virtual Machine implementation name  java.specification.version - Java Runtime Environment specification version  java.specification.vendor - Java Runtime Environment specification vendor  java.specification.name - Java Runtime Environment specification name  java.class.version - Java class format version number  java.class.path - Java class path  java.library.path - List of paths to search when loading libraries  java.io.tmpdir - Default temp file path  java.compiler - Name of JIT compiler to use  java.ext.dirs - Path of extension directory or directories  os.name - Operating system name  os.arch - Operating system architecture  os.version - Operating system version  file.separator - File separator ("/" on UNIX)  path.separator - Path separator (":" on UNIX)  line.separator - Line separator ("\n" on UNIX)  user.name - User's account name  user.home - User's home directory  user.dir - User's current working directory  
like image 114
Suraj Chandran Avatar answered Sep 27 '22 23:09

Suraj Chandran