如何调用项目中的exe文件?
我把一个exe文件复制到Java项目的libs文件夹
然后想在程序中调用开启:
Runtime.getRuntime().exec("libs/calc.exe");
//www.luger.meimport java.io.File;public class Test2 { public static void main(String[] args) throws Exception { System.out.println(Thread.currentThread().getContextClassLoader() .getResource("")); System.out.println(Test2.class.getClassLoader().getResource("")); System.out.println(ClassLoader.getSystemResource("")); System.out.println(Test2.class.getResource("")); System.out.println(Test2.class.getResource("/")); // Class文件所在路径 System.out.println(new File("/").getAbsolutePath()); System.out.println(System.getProperty("user.dir")); //获得执行文件的绝对路径 }}/*file:/F:/JavaCode/bin/file:/F:/JavaCode/bin/file:/F:/JavaCode/bin/file:/F:/JavaCode/bin/file:/F:/JavaCode/bin/F:\F:\JavaCode*/