Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Run an exe file from JSP

Posted on 2001-09-18
6
Medium Priority
?
970 Views
Last Modified: 2011-10-03
I would like to execute an exe file from a JSP page. How should i do that? The JSP page and the exe file are located in the same server.

for example:
I have a jsp page(RunExe.jsp) which need to execute an exe file that located at C:\ExeFile\ExeFile.exe

When user request the RunExe.jsp, the jsp page will pass some parameter to ExeFile.exe and execute it. After that the ExeFile.exe will return the result back to the RunExe.jsp and the result will displayed out.


How should i do that? What package should i import? Need advise and example code. Appreciate any help.
0
Comment
Question by:aGuyNameRay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 6490341
Runtime.getRuntime().exec(...);
0
 
LVL 1

Author Comment

by:aGuyNameRay
ID: 6490481
The exe file pass out a result, how can i get the result and display it out?
0
 
LVL 1

Author Comment

by:aGuyNameRay
ID: 6490491
The exe file pass out a result, how can i get the result and display it out?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 16

Accepted Solution

by:
heyhey_ earned 300 total points
ID: 6490516
Process p = Runtime.getRuntime().exec("yourApp.exe");
InputStream is = p.getInputStream();
int n;
while ((n = is.read()) != -1)
{
  // save read char
}
0
 
LVL 2

Expert Comment

by:ia_ia_ia_1
ID: 6490520
Something like:

            Process pr = Runtime.getRuntime().exec("cmd.exe");  // replace with you exe


            pr.waitFor();

            java.io.InputStream in = pr.getInputStream();

            java.io.InputStreamReader rdr = new java.io.InputStreamReader(in);
            char[] buffer = new char[1024];

            while (true) {
                int i = rdr.read(buffer);
                if (i == -1) break;
                System.out.print(buffer);
            }

            rdr.close();
0
 

Expert Comment

by:hieutd
ID: 6490879
Listening...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question