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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
javacommand 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 appropriatejavacommand 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.