Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Run a .exe file using Spring

  1. #1
    Join Date
    Jun 2007
    Posts
    13

    Default Run a .exe file using Spring

    Hi,
    i have a .exe, which i need to execute from my java code(using spring frame work).

    I have two cases:
    1) .exe file is in local system.
    2) .exe file is in remote

    Are there any API's available in spring framework to do this.

    Thanks for any help.

    Ramya.

  2. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    I would do a general search on the net for running executing exe's from Java.
    Last edited by karldmoore; Aug 29th, 2007 at 11:53 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  3. #3
    Join Date
    Jun 2007
    Posts
    13

    Default

    Hi,
    Thanks for that, is there any package provided by the spring for that.
    i Need to call the exe file which is located in the remote system.
    I am using java's Runtime

    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("C:\\software\\npp.4.0.2.Installer.exe");
    int exitVal = proc.exitValue();
    System.out.println("Process exitValue: " + exitVal);


    Is there any thing specific that i have to do to execute a remote file.
    I heard about socket programming, to how extent it will be useful to me.

    Thanks for any help.

    Ramya.

  4. #4
    Join Date
    Aug 2006
    Posts
    26

    Default

    This isn't really a Spring issue but...

    What exactly do you mean by executing a remote file? There's no inherent way to execute a file on a remote system, but there are a few options...

    a) Map it to the local computer so that it appears to be a local file. This will run on your system but be stored remotely.

    b) Run a server on the remote system that calls Runtime.exec() there. You can do this using the ServerSocket interface or any other language, but it's kind of hacky.

    c) Run a remote service using RMI that does the same. Slightly less hacky, but requires Java and some additional constraints.

    d) Run a service through some other server container, using some form of CGI or something, possibly calling it via JNDI. I suppose if you really wanted to, you could develop a Spring servlet on the remote computer and have your local servlet post HTTP to it...

    e) Make it a web service and call it with SOAP. This is probably the most elegant and buzzword-compliant option.

    Without knowing more about the situation, I really can't suggest anything else. It depends on how much control you have over the remote system, how many resources you want to occupy, how much effort you want to put into it and how strong/secure/etc you want it to be.

  5. #5
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    I'm with the other poster here, I'm confused about what you are actually trying to do. Executing remote files using sockets? Any chance you can explain a little more about what you're trying to do?
    Last edited by karldmoore; Aug 29th, 2007 at 11:52 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  6. #6
    Join Date
    Jun 2007
    Posts
    13

    Default

    Hi,
    sorry for the late reply.
    What i am trying to say is, there is an executable file say for example addmember.exe(adds a member to a database and some other stuff...) in a remote system. From my java code i need to invoke the exe file so that it is executed in the remote system and adds a member to a database.

    For example:
    Process p = Runtime.getRuntime().exec("C:\member\addmember.exe ");

    I can use java api like this to run the exe file.Still i need to find out how to run if this file is there on a remote system.

    Is there any spring specific ways of doing this, with out using the usual java API.

    Thanks for any help.

    Thanks,
    Ramya.
    Last edited by ramyareddy; Jun 26th, 2007 at 05:20 AM.

  7. #7
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Quote Originally Posted by ramyareddy View Post
    Hi,
    sorry for the late reply.
    What i am trying to say is, there is an executable file say for example addmember.exe(adds a member to a database and some other stuff...) in a remote system. From my java code i need to invoke the exe file so that it is executed in the remote system and adds a member to a database.

    For example:
    Process p = Runtime.getRuntime().exec("C:\member\addmember.exe ");

    I can use java api like this to run the exe file.Still i need to find out how to run if this file is there on a remote system.

    Is there any spring specific ways of doing this, with out using the usual java API.

    Thanks for any help.

    Thanks,
    Ramya.
    No. This is not in the Spring remit.

  8. #8
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    The remoting side of this is fine, there are lots of non-Spring and Spring ways of doing this. As for the actual call what's wrong with what you have?
    http://www.springframework.org/docs/.../remoting.html
    Last edited by karldmoore; Aug 29th, 2007 at 11:52 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  9. #9
    Join Date
    Jun 2007
    Posts
    13

    Default

    addmember.exe requires two input parameters, which i used to pass through command prompt.With java Runtime(Process p = Runtime.getRuntime().exec("C:\member\addmember.exe ) i didn't have a chance to pass input parameters to the exe.

    Is there any other way to pass parameters to the exe.

    Thanks,
    Ramya.

  10. #10
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Lightbulb

    Would you like first look into the Javadoc for Runtime class, and only then ask questions?

    This class contains a horde of different versions of the exec() method which allow for passing parameters, specifying environment variables and working directory.

    For example
    Process exec(String[] cmdarray)
    Executes the specified command and arguments in a separate process.


    Regards,

    Oleksandr
    Quote Originally Posted by ramyareddy View Post
    addmember.exe requires two input parameters, which i used to pass through command prompt.With java Runtime(Process p = Runtime.getRuntime().exec("C:\member\addmember.exe ) i didn't have a chance to pass input parameters to the exe.

    Is there any other way to pass parameters to the exe.

    Thanks,
    Ramya.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •