当前位置: 技术问答>linux和unix
达人帮忙爱!!! Linux下无法调用.o文件!!!
来源: 互联网 发布时间:2015-12-22
本文导语: // 代码 ------------------------------------------------------------------------- package myPack; import java.io.File; public class Test { public static void main(String[] args) { File file = new File("/root/test.o"); if(file.exists()){ System.out.pr...
// 代码 -------------------------------------------------------------------------
package myPack;
import java.io.File;
public class Test {
public static void main(String[] args) {
File file = new File("/root/test.o");
if(file.exists()){
System.out.println("Exists!");
try {
Process procStart = Runtime.getRuntime().exec("./root/test.o");
procStart.waitFor();
}
catch (Exception e)
{
e.printStackTrace();
}
}
else
System.out.println("Not exists!");
}
}
// 以下是报错 ---------------------------------------------------------------------
Exists!
java.io.IOException: java.io.IOException: ./root/test.o: not found
at java.lang.UNIXProcess.(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
at java.lang.Runtime.exec(Runtime.java:591)
at java.lang.Runtime.exec(Runtime.java:429)
at java.lang.Runtime.exec(Runtime.java:326)
at myPack.Test2.main(Test2.java:13)
请问如何才能调用test.o文件.
package myPack;
import java.io.File;
public class Test {
public static void main(String[] args) {
File file = new File("/root/test.o");
if(file.exists()){
System.out.println("Exists!");
try {
Process procStart = Runtime.getRuntime().exec("./root/test.o");
procStart.waitFor();
}
catch (Exception e)
{
e.printStackTrace();
}
}
else
System.out.println("Not exists!");
}
}
// 以下是报错 ---------------------------------------------------------------------
Exists!
java.io.IOException: java.io.IOException: ./root/test.o: not found
at java.lang.UNIXProcess.(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
at java.lang.Runtime.exec(Runtime.java:591)
at java.lang.Runtime.exec(Runtime.java:429)
at java.lang.Runtime.exec(Runtime.java:326)
at myPack.Test2.main(Test2.java:13)
请问如何才能调用test.o文件.
|
./root/test.o
/root/test.o
/root/test.o
|
./文件名
|
关注
|
静态库.o能执行吗