• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

run exe in client sid

 
raktim banerjee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello sir!

I had been trying to run executable file on the client side using jsp and servlet. The following code for running notepad.exe is working properly.


But i wrote this for running my own exe. There is no error in the error console of browser. But there is no expected output.



I am new in this field. Please help me regarding this matter.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't be done. Servlet code runs on the server. If you want such behaviour (and you want to use Java) you will need a signed Applet running the in the client browser.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlets and JSP run on the server, not the client. So you cannot cause a client-side program to run. Imagine the security nightmare if you could!

If you need to run something on the client, you'll need to use an Applet or Java Web Start.

[Edit: Paul beat me to it]
 
raktim banerjee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir! I want to know both about runing exe in server side and client cide. I understand in case of server side i have to use servlet, and for client side applet.
In case of running exe using servlet, the code for running notepad.exe is working but the code for running my own exe is not working. what is the cause?

And how to run exe in client side using applet, please suggest me something.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In case of running exe using servlet, the code for running notepad.exe is working but the code for running my own exe is not working. what is the cause?

What do the logs say?


And how to run exe in client side using applet, please suggest me something.[

The code will be very similar, but the Applet will need to be signed. See this.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For executing with Runtime this article is a must read: When Runtime.exec() won't
 
raktim banerjee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is nothing in logs. No error report.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but the code for running my own exe is not working.



I would bet that your exe makes use of std out and/or std err output streams. Read the article Wouter pointed to.

Since notepad uses a window and does not use std out or std err, it does not hit this problem.

Bill

 
parampreet sethi
Greenhorn
Posts: 27
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just a quick question here,

Since notepad uses a window and does not use std out or std err, it does not hit this problem.


Does it mean that any program which uses a window (basically window application) can be run on client side through servlet?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
parampreet sethi wrote:Does it mean that any program which uses a window (basically window application) can be run on client side through servlet?

No. It's already been pointed out that servlets cannot cause client-side programs to execute.
 
raktim banerjee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would bet that your exe makes use of std out and/or std err output streams. Read the article Wouter pointed to.


Sir, with respect,

I am not using any std out or std err in my exe, which i want to run using servlet in the server side. The functionality of the exe is: It reads a string from a .txt file and watermark(invisible) in a picture. The output is a .m file. I made this exe using MATLAB compilor (mcc).

The exe, which i want to run using applet in the client side, takes input a .m file, extract the watermark and write it back in a .txt file.


 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With respect eh? Well us aged Java gurus can always use a little respect.

Are you absolutely there is never any output to std out or std err? What do you with exceptions for example? If you don't catch and log them the JVM will try to write to std err.

Bill
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoops I just reread the thread and see the .exe is a C program but the same question applies. The C runtime will write to std err if it gets an error - for example what happens if the file is not found?

Bill
 
raktim banerjee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did not handle the exceptions in the MATLAB code before making exes. But the exes are working well when i am executing these manually. I checked that exec() is not working with any DOS based executable file, but it is working well with windos executable files. Is there any problem?
 
raktim banerjee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoops I just reread the thread and see the .exe is a C program but the same question applies. The C runtime will write to std err if it gets an error - for example what happens if the file is not found?


The servlet or applet code will check if the file exists or if there is another exceptions. Then it will call those exes.

Now is there any way?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I repeat the suggestion - read the article Wouter suggested and follow the advice for consuming and displaying the std out and std err streams to find out why the exec is not working.

You might also want to read the java.lang.Process documentation about handling those streams.

Can you get a look at the executing processes on the server side when trying to run your .exe? In windows this would be via the Windows Task manager - if it shows your encryption.exe as just sitting there with no execution time, that should give you a hint.

Bill
 
raktim banerjee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At last i have done it. Many time I run the code. As encryption.exe and decryption.exe do not use any std output and lifetime is very sort, I was confused about the execution of these two exes. I expected the output in the same directory where the exe is. But i found the output in:



I wrote this:




This code worked.
That link helped me a lot. Also learned so many things about exec(). Now i will try to use the same code in applet for client side.

Thank you very much Sir William Brogden, Sir Paul Sturrock, Sir Paul Sturrock and Sir Wouter Oet.

With respect eh? Well us aged Java gurus can always use a little respect.


Want to say something to William Brogden,
The word "guru" is a Bengali word, Derived from Sanskrit "gurudev", means lord. We often use this word in our mother tongue.
Thanks a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic