Application Scenario Description:
Java Web program, triggering the call C # written in the background EXE program, found in the EXE written files cannot be found. Execute the exe under the cmd command line alone no problem;
Problem Lookup:
Because EXE gets the file path error caused;
Workaround:
EXE in the Get program path instead:
String pathlog = System.Reflection.Assembly.GetExecutingAssembly (). Location;
Pathlog = pathlog.substring (0, Pathlog.lastindexof (@ "\")) + "/log.txt";
Appendix: Java ESC EXE code:
public void Exetest () {
String Mainexepath = "F:\\trans2json\\trans2json.exe", prjid= "1", mid= "104", modelexepath= "", modelparamspath= "", type ="",
Contourlineexepath= "", contourlineparamspath= "";
try {
Process Process = Runtime.getruntime (). EXEC (Mainexepath + "all 1 104");
BufferedReader br = new BufferedReader (New InputStreamReader (Process.getinputstream ()));
String str;
while ((str = br.readline ()) = null)
{
System.out.println (str);
}
SYSTEM.OUT.PRINTLN ("Success");
}catch (Exception e) {
System.out.println ("Calculation failed");
}
}
Java Tune C # exe program, exe write file problems