Thursday, 12 September 2013

Trying to make a web application send info to an executable on my machine using Java

Trying to make a web application send info to an executable on my machine
using Java

I have some java code that communicates with an executable that is on my
machine which codes certain orders based on four files and user input the
code for that is as follows:
void coder(File exe, File ord, File cod, File msg, File rls, String tcc )
throws ProcessException {
String[] cmd = {
exe.getPath(), // Executable
ord.getPath(), // InputOrder (IN)
cod.getPath(), // ResultsCodedOrder (OUT)
msg.getPath(), // Messages (OUT)
rls.getPath(), // Releases (IN)
tcc //User input
};
Process proc = null;
try {
proc = Runtime.getRuntime().exec(cmd); // Code the order.
} catch (IOException ioe) {
ioe.printStackTrace();
throw new ProcessException("IOException. Could not exec command.");
}
Within the same file I have coder actually putting in certain values for
the user input string and for the user made files here:
// This illustrates the (idealized) steps neccessary to code an order.
Order codeOrder(File taskdir, Order order) throws ProcessException {
String ordername = order.getName();
// Create temp 'input' files.
File orderFile = createTriconOrderFile(taskdir, order);
File releaseFile = createTriconReleaseFile(taskdir, order);
// Define temp 'output' files.
File messageFile = new File(taskdir, ordername + msgExt);
File codedFile = new File(taskdir, ordername + codExt);
// Code order.
coder(exe,
orderFile,
codedFile,
messageFile,
releaseFile,
"valsel");
I would like to change this based on a user's preference and not have it
hard coded as 'valsel' and rather whatever the user decides...Any ideas on
how this may be implemented...
// Delete temp files.
// If there is an exception while coding the Task, these won't be
deleted.
// This is good because we can examine these files.
deleteTempFile(releaseFile);
deleteTempFile(codedFile );
deleteTempFile(messageFile);
deleteTempFile(orderFile );
return codedOrder;
}

No comments:

Post a Comment