[java] How to get the real path of Java application at runtime?

The expression

new File(".").getAbsolutePath();

will get you the current working directory associated with the execution of JVM. However, the JVM does provide a wealth of other useful properties via the

System.getProperty(propertyName); 

interface. A list of these properties can be found here.

These will allow you to reference the current users directory, the temp directory and so on in a platform independent manner.