using Java code to fetch C # applications and implement data interaction
This article mainly introduces applications that call C # through Java and passes parameters to C # clients. Before doing the project encountered this function, by the way to share the code out;
Requirements:
1.java is the web framework, deployed in the server
2.c# client (is EXE file) placed in the server, C # program is responsible for the transfer of another service data
3.javaweb projects and C # clients are in the same server
3. Require Java code to start a C # program and pass a parameter to C #; C # is the console program Main method
4. It is more noteworthy that the C # client code has access to the network drive disk path, the network drive disk (meaning that the disk of another server is mapped to the local server to access the path), so there is a big problem,
It is no problem to manually start the C # client directly in the server, you can access the network drive disk path; The problem is, the Javaweb front button executes Java code to fetch the C # client, when the C # client cannot find the network Map drive path, and therefore needs to modify the C # code. Implement network drive disk sharing. There is no introduction to a Web-driven application that cannot access the network drive, and put it on another blog.
implementation:
Java code:
/**
*command is an EXE path, such as (D:\\c#.exe)
*param is the parameter passed to the EXE
* Note Do not use process to fetch the program, because cannot pass the parameter
**/
Private Boolean Execbat (String command,string param) {
try {
Processbuilder p= New Processbuilder (Command,param);/only use Processbuilder, no process
P.start ();
catch (IOException e) {
return false;
}
return true;
}