Java Tune C # exe program, exe write file problems

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.