If we want to programmatically determine what version of the Java Runtime Environment
(JRE) is being used to execute a given application then, we can get the version via the following code illustrates:
//IN WINDOWS PLATFORM
String ver = System.getProperty("java.version"));
System.out.println("This program is running under JRE version " + ver);
if (ver.startsWith("1.5")) {
// Pseudocode.
do something appropriate for newer versions of Java ...
}
else {
// Pseudocode.
do something the pre-5.0 way ...
}
Some of the java System Properties based on JDK 1.5 are given as follows:
| Key | Description of Associated Value |
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 temporary 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 |
The following table describes some of the most important system properties BASED on JDK 1.6
| Key | Description of Associated Value |
"file.separator" |
Character that separates components of a file path. This is “ /” on UNIX and “\” onWindows. |
"java.class.path" |
Path used to find directories and JAR archives containing class files. Elements of the class path are separated by a platform-specific character specified in the path.separator property. |
"java.home" |
Installation directory for Java Runtime Environment (JRE) |
"java.vendor" |
JRE vendor name |
"java.vendor.url" |
JRE vender URL |
"java.version" |
JRE version number |
"line.separator" |
Sequence used by operating system to separate lines in text files |
"os.arch" |
Operating system architecture |
"os.name" |
Operating system name |
"os.version" |
Operating system version |
"path.separator" |
Path separator character used in java.class.path |
"user.dir" |
User working directory |
"user.home" |
User home directory |
"user.name" |
User account name |
Filed under: Classes, Object Core | Tagged: java, key, properties, System, windows

You forgot to mention that you can set system properties at JVM invocation.
You also didn’t mention that your example has problems of its own – determining the JVM version is trivial. Acting on it can be difficult. The only way to make sure that your program runs on a certain (older) version of Java is to compile and test it with that JVM. But then, the part for the newer-version JVM might not compile anymore. And if you compile it all with the newer version, the “old way” might accidentally call methods/classes that aren’t there.
A *useful* example – something many don’t do but should – would be grabbing the line.separator property instead of adding “\n” to try to force a line break, because the different platforms have different line separators (\n for Linux, \r\n for Windows and \r for Macs IIRC).
those all code written specially for jdk 1.5 and
i know well abt “\n”