Executing an external program from Java/JavaScript.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Executing an external program from Java/JavaScript.

  1. #1
    Jose Rodz Guest

    Executing an external program from Java/JavaScript.


    Is there a function that can use in Java or JavaScript to run an external
    program from within the Java Class or JavaScript Function?

  2. #2
    Paul Clapham Guest

    Re: Executing an external program from Java/JavaScript.


    "Jose Rodz" <rodriguezj.orion@afwtf.navy.mil> wrote in message
    news:3d81d16c$1@10.1.10.29...
    >
    > Is there a function that can use in Java or JavaScript to run an external
    > program from within the Java Class or JavaScript Function?


    Java: Runtime.getRuntime().exec("extprog.exe");

    Javascript: Don't know, I hope not because that would be an enormous
    security hole in browsers.



  3. #3
    Jose Rodz Guest

    Re: Executing an external program from Java/JavaScript.


    "Paul Clapham" <pclapham@core-mark.com> wrote:
    >
    >"Jose Rodz" <rodriguezj.orion@afwtf.navy.mil> wrote in message
    >news:3d81d16c$1@10.1.10.29...
    >>
    >> Is there a function that can use in Java or JavaScript to run an external
    >> program from within the Java Class or JavaScript Function?

    >
    >Java: Runtime.getRuntime().exec("extprog.exe");
    >
    >Javascript: Don't know, I hope not because that would be an enormous
    >security hole in browsers.
    >
    >

    Thanks.. Can this function work in a Java Servlet?


  4. #4
    MarkN Guest

    Re: Executing an external program from Java/JavaScript.


    Yes. A servlet is just another java class. It will need to have access to
    where the exe is located - just like the app - just easier to forget.


    "Jose Rodz" <rodriguezj.orion@afwtf.navy.mil> wrote:
    >
    >"Paul Clapham" <pclapham@core-mark.com> wrote:
    >>
    >>"Jose Rodz" <rodriguezj.orion@afwtf.navy.mil> wrote in message
    >>news:3d81d16c$1@10.1.10.29...
    >>>
    >>> Is there a function that can use in Java or JavaScript to run an external
    >>> program from within the Java Class or JavaScript Function?

    >>
    >>Java: Runtime.getRuntime().exec("extprog.exe");
    >>
    >>Javascript: Don't know, I hope not because that would be an enormous
    >>security hole in browsers.
    >>
    >>

    >Thanks.. Can this function work in a Java Servlet?
    >



  5. #5
    Jose Rodz Guest

    Re: Executing an external program from Java/JavaScript.


    The executable should be in same directory as the servlet? I have placed there
    and it gave me an IllegalStateException. I wasn't sure if was the function
    causing the problem or the external executable. Thanks for the info.

    "MarkN" <java.@127.0.0.1> wrote:
    >
    >Yes. A servlet is just another java class. It will need to have access

    to
    >where the exe is located - just like the app - just easier to forget.
    >
    >
    >"Jose Rodz" <rodriguezj.orion@afwtf.navy.mil> wrote:
    >>
    >>"Paul Clapham" <pclapham@core-mark.com> wrote:
    >>>
    >>>"Jose Rodz" <rodriguezj.orion@afwtf.navy.mil> wrote in message
    >>>news:3d81d16c$1@10.1.10.29...
    >>>>
    >>>> Is there a function that can use in Java or JavaScript to run an external
    >>>> program from within the Java Class or JavaScript Function?
    >>>
    >>>Java: Runtime.getRuntime().exec("extprog.exe");
    >>>
    >>>Javascript: Don't know, I hope not because that would be an enormous
    >>>security hole in browsers.
    >>>
    >>>

    >>Thanks.. Can this function work in a Java Servlet?
    >>

    >



  6. #6
    Jun Wu Guest

    Re: Executing an external program from Java/JavaScript.


    "Jose Rodz" <rodriguezj.orion@afwtf.navy.mil> wrote:
    >
    >The executable should be in same directory as the servlet? I have placed

    there
    >and it gave me an IllegalStateException. I wasn't sure if was the function
    >causing the problem or the external executable. Thanks for the info.
    >
    >"MarkN" <java.@127.0.0.1> wrote:
    >>
    >>Yes. A servlet is just another java class. It will need to have access

    >to
    >>where the exe is located - just like the app - just easier to forget.
    >>
    >>
    >>"Jose Rodz" <rodriguezj.orion@afwtf.navy.mil> wrote:
    >>>
    >>>"Paul Clapham" <pclapham@core-mark.com> wrote:
    >>>>
    >>>>"Jose Rodz" <rodriguezj.orion@afwtf.navy.mil> wrote in message
    >>>>news:3d81d16c$1@10.1.10.29...
    >>>>>
    >>>>> Is there a function that can use in Java or JavaScript to run an external
    >>>>> program from within the Java Class or JavaScript Function?
    >>>>
    >>>>Java: Runtime.getRuntime().exec("extprog.exe");
    >>>>
    >>>>Javascript: Don't know, I hope not because that would be an enormous
    >>>>security hole in browsers.
    >>>>
    >>>>
    >>>Thanks.. Can this function work in a Java Servlet?
    >>>

    >>

    >



    There is a way to run a DOS command from HTML, from which you can start an
    external program. The method has been published by Simon Tong in following
    web page:

    http://www.devx.com/free/tips/tipvie...ontent_id=3675

    I copied the content here too:


    Run a DOS Command From an HTML Page

    This is achieved by using the Windows Script Host. First, create an instance
    of the object WScript.Shell. Then, use its Run method to execute the DOS
    command. For example, say your HTML page has a button that will run the DIR
    command when clicked. The onclick jscript function would look something like
    this:

    -------------------------
    function btnDIR_onclick()
    {
    var WshShell = new ActiveXObjec("WScript.Shell");
    WshShell.Run("%comspec% /c DIR");
    WshShell.Quit;
    }
    ----------------------------


    The %comspec% string in the argument for Run() specifies the path and file
    name of the command interpreter, Cmd.exe.

    Simon Tong
    Melbourne, Australia


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center