在java中运行fortran exe [英] Run fortran exe in java
问题描述
我有一个fortran exe文件,它通过对输入文件进行一些操作来获取输入文件并生成输出文件。我能够运行(我认为fortran编译器在linux中是可用的)。现在请建议如何使用java(在Linux机器上)运行这个fortran可执行文件。
我尝试的是,
String cmd =fortranExe arg1 arg2;
// fortranExe = exe路径
// arg1,arg2是Fortran可执行程序的参数
进程p = Runtime.getRuntime()。exec(cmd);
但是我没有得到输出。当我试图运行ls等Linux命令时,dir正在给出在java中运行fortran代码需要什么?
尝试使用类似这样的内容
Process process = new ProcessBuilder(C:\\PathToExe\\fortran.exe,param1,param2)。start );
从
有关ProcessBuilder的更多信息: http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/ProcessBuilder.html
Respected sir/madam,
I have a fortran exe which takes a input file and produces output file by doing some manipulation on input file.I am able to run the command in linux terminal.(I think fortran compiler is availble in linux).Now please suggest how to run this fortran executable file using java(in Linux machine).
What i attempted is,
String cmd="fortranExe arg1 arg2";
//fortranExe=exe path
//arg1,arg2 are arguments to fortran executable program
Process p=Runtime.getRuntime().exec(cmd);
But i am not getting output.When i tried to run Linux commands such as ls,dir are giving output.Is anything required for running fortran code in java?
Try using something like this
Process process = new ProcessBuilder("C:\\PathToExe\\fortran.exe","param1","param2").start();
Got this from
Java Programming: call an exe from Java and passing parameters
More info on ProcessBuilder: http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/ProcessBuilder.html
这篇关于在java中运行fortran exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!