String javaHome = System.getProperty("java.home");
Can you tell me either through pure Java … on windows how is it possible to find out the location of javaw.exe?
例如.
import java.io.File;
class JavawLocation {
public static void main(String[] args) {
String javaHome = System.getProperty("java.home");
File f = new File(javaHome);
f = new File(f, "bin");
f = new File(f, "javaw.exe");
System.out.println(f + " exists: " + f.exists());
}
}
产量
C:\Program Files (x86)\Java\jdk1.6.0_29\jre\bin\javaw.exe exists: true
Press any key to continue . . .
是的,我有信心在JRE工作.