plz post how to know os installed drive
plz
Printable View
plz post how to know os installed drive
plz
Other than interpreting the things in the "java.class.path" java environment (system property) variable, like to try to guess the "C:" parts if there are any, there is no built-in Java property to say what the operating system installation drive is.
Nor, is there any built-in way to read the system environment variable settings. Also note that the os "installed drive" is specific to Windows operating systems.
You can try setting your own -DOS_INSTALL_DRIVE=%SYSTEM_ROOT% in the Java command line or batch file that launches your application, where in this example the %SYSTEM_ROOT% thing would be an environment variable [you] set up ahead of time, or possibly what ever environment variable that comes set with windows.
I generally use the following utility to sniff out all the currently set Java environment properties.
Code:import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
/**
* Prints a sorted list of system properties to the stdout.
* @author thein
*
*/
public class DumpSystemProperties {
public static void main(String[] args) {
Properties p = System.getProperties();
Map<String, String> sortedProperties = new TreeMap<String, String>();
for (Object key : p.keySet()) {
sortedProperties.put(key.toString(), p.getProperty(key.toString()));
}
for (String key: sortedProperties.keySet()) {
System.out.println(key + ":" + sortedProperties.get(key));
}
}
}