Possible Duplicate:
Execute another jar in a java program
I have an executable jar file that accepts two parameters: an input file and an output file:
java -jar inputFile.txt outputFile.txt
How can I call exactly this from JavaScript?
Possible Duplicate:
Execute another jar in a java program
I have an executable jar file that accepts two parameters: an input file and an output file:
java -jar inputFile.txt outputFile.txt
How can I call exactly this from JavaScript?
The answer depends on the context.
If your javascript is running in a web browser sandbox, then the answer is that you can't run a JAR file. The sandbox is designed to stop you doing that kind of thing.
If your javascript is running under node.js, then this SO Q&A offers a solution to the problem of running a command:
How do I run the system commands in javascript?. This can be used to run the java
command with the appropriate args.
If your javascript is trusted code running in a browser with a Java plugin, then you may be able to make a call to java.lang.System.exec(...)
passing an appropriate java
command line in the appropriate fashion. You may also be able to create a classloader, read the JAR file's manifest, extract the entry point class, load it, and call the "main" method.
java -jar executable.jar inputFile.txt outputFile.txt
For further details see the java command synopsis:
SYNOPSIS