我用java调用批处理文件.bat,请问怎么把绝对路径改成相对路径。代码如下:
public void runbat() {
String cmd = "cmd /c start E:/tr/bin/win32/text.bat";
try {
Process ps = Runtime.getRuntime().exec(cmd);
System.out.println(ps.getInputStream());
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
public void runbat() {
String cmd = "cmd /c start E:/tr/bin/win32/text.bat";
try {
Process ps = Runtime.getRuntime().exec(cmd);
System.out.println(ps.getInputStream());
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
然后就可以在 bat文件里面 直接写上 :
javac 主类名(带main方法).java
java 主类名(带main方法)保存后 直接点击bat文件 即可运行啊
方法有很多 或许有缺陷 不过LZ可以试试看 ...
这个问题还是比较普遍的.搜索一下有一大堆答案
得到当前的路径