I want to execute "jar.exe" from my code using
Process p = Runtime.getRuntime().exec("jar.exe -xf " + completePathToJar);
but I only want to call it if the jar.exe really exists (the jdk is installed). How can I make sure the jar.exe really exists on the machine?
Thanks for your help.
To check weather the file exists or not use File class
File exeFile = new File(validExeFilePath);
if(exeFile.exists()){
Process p = Runtime.getRuntime().exec("jar.exe -xf " + completePathToJar);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.