How can native executable files be started from within a Java application.

Hi Everyone,
I am currently working on an application that will have the ability to start a program within Windows. What I intend on having is a button within my GUI that can start Microsoft Word. I am completely lost as to where I should begin in order to make this work. If anybody has any pointers they will be greatly appreciated. Thanks.
Regards
D

Hi ,
easy:
Runtime.getRuntime().exec(new String[]{path,name});
see:
http://java.sun.com/j2se/1.3/docs/api/java/lang/Runtime.html
HTH

Similar Messages

  • How can I execute an external program from within a button's event handler?

    I am using Tomcat ApacheTomcat 6.0.16 with Netbeans 6.1 (with the latest JDK/J2EE)
    I need to execute external programs from an event handler for a button on a JSF page (the program is compiled, and extremely fast compared both to plain java and especially stored procedures written in SQL).
    I tried what I'd do in a standalone program (as shown in the appended code), but it didn't work. Instead I received text saying the program couldn't be found. This error message comes even if I try the Windows command "dir". I thought with 'dir' I'd at least get the contents of the current working directory. :-(
    I can probably get by with cgi on Apache's httpd server (or, I understand tomcat supports cgi, but I have yet to get that to work either), but whatever I do I need to be able to do it from within the button's event handler. And if I resort to cgi, I must be able to maintain session jumping from one server to the other and back.
    So, then, how can I do this?
    Thanks
    Ted
    NB: The programs that I need to run do NOT take input from the user. Rather, my code in the web application processes user selections from selection controls, and a couple field controls, sanitizes the inoputs and places clean, safe data in a MySQL database, and then the external program I need to run gets safe data from the database, does some heavy duty number crunching, and puts the output data into the database. They are well insulated from mischeif.
    NB: In the following array_function_test.pl was placed in the same folder as the web application's jsp pages, (and I'd tried WEB-INF - with the same result), and I DID see the file in the application's war file.
            try {
                java.lang.ProcessBuilder pn = new java.lang.ProcessBuilder("array_function_test.pl");
                //pn.directory(new java.io.File("K:\\work"));
                java.lang.Process pr = pn.start();
                java.io.BufferedInputStream bis = (java.io.BufferedInputStream)pr.getInputStream();
                String tmp = new String("");
                byte b[] = new byte[1000];
                int i = 0;
                while (i != -1) {
                    bis.read(b);
                    tmp += new String(b);
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + tmp);
            } catch (java.io.IOException ex) {
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + ex.getMessage());
            }

    Hi Fonsi!
    One way to execute an external program is to use the System Exec.vi. You find it in the functions pallet under Communication.
    /Thomas

  • How to execute a Perl program from within a Java prog

    How do I execute a Perl program from within a Java program.
    Lets say the Perl program that I want to execute is 'abc'. Now, 'abc' requires some input that I want to give it from within the Java program. How do I do it?
    And finally, how do I execute that Perl program from within the Java program.
    If I execute the Perl program alone then I do it in the following way -
    perl abc inp1 inp2 inp3
    where inp1, inp2, inp3 are inputs to the Perl program. I will not be able to change or modify the coding of the Perl program - 'abc' as I do not have access to its code. Its a kind of an application whose usual method of execution is in the above shown way. So, how do I execute 'abc' from within a Java program.

    what part of don't crosspost, don't you understand?
    http://forum.java.sun.com/thread.jsp?forum=4&thread=427193

  • Executing a Perl program from within a Java prog

    How do I execute a Perl program from within a Java program.
    Lets say that the Perl program that I want to execute is 'abc'.'abc' requires some input that I want to give from within the java program. How do I do that? Then I want to execute the Perl program from within the Java prog. How do I do it?

    don't crosspost.
    http://forum.java.sun.com/thread.jsp?forum=31&thread=427211&tstart=0&trange=100

  • How can i set my calendar start from Monday NOT Sunday like it is now?

    How can i set my calendar start from Monday NOT Sunday like it is now?

    Read this thread: https://discussions.apple.com/message/11501621#11501621
    For example, if you set the Regional format to United Kingdom, the days will be re-ordered but it will have other effects as well which you probably don't want.

  • How can I send files via Bluetook from my Tour to other phones?

    How can I send files via Bluetook from my Tour to other phones?
    I have even been able to pair to the other device, but I don't see the option to send/copy/move files through Bluetooth.
    I can only send my Address book via bluetooth.
    Please help!!

    Hi and Welcome to the Community!
    See this KB:
    KB05409 Transfer a file using Bluetooth technology between two BlackBerry smartphones
    Substitute, in the KB, the appropriate instructions for your other device in place of the KB section for the receiving device. Be aware that RIM only supports BT file transfer between BBs...with other devices is technically unsupported. But, it usually works, as long as the two devices are paired, trusted to each other, and each have all of the correct BT services enabled for the configuration of the other device.
    Good luck and let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • How can I manipulate Selenium IDE addon in my own java application..??

    How can I manipulate Selenium IDE addon using my own java application..??
    Is there any .jar file available for it..??
    Actually I'm working on a project of automation framework. For this I want to link the "Record" button and "Menu bar"(at the top of the IDE).
    I'm using Eclipse on Win7 Ultimate(x64).
    Please provide the required links or documentations.
    I would really appreciate your kind help..

    I'm sorry, we don't generally have that kind of information in this forum. I'd suggest asking the developer of the add-on. If you're using [https://addons.mozilla.org/en-us/firefox/addon/selenium-expert-selenium-ide/ Selenium Expert (Selenium IDE)], the support link listed is http://blog.reallysimplethoughts.com/

  • How can I import file of photos from external drive into photoshop elements 11 organizer?

    I just started with elements 11 after many years of El., 10. How can I import files from external disk to elements 11 organizer? My files were stored on the external drive.

    Hi,
    The Canon S100 wasn't supported until version 6.6 of camera raw and that isn't supported by pse 8.
    You options are to either upgrade to pse version 10 or use the DNG converter
    for windows http://www.adobe.com/support/downloads/detail.jsp?ftpID=5310
    or
    for mac http://www.adobe.com/support/downloads/detail.jsp?ftpID=5309
    Brian

  • How can I transfer files and settings from a PC to a mac

    How can I transfer data and settings from PC to mac via cable as the method via the network seems excessively slow. What cables do I need Ethernet USB?

    This Apple Article may help.

  • How can i load file into database from client-side to server-side

    i want to upload file from client-side to server-side, i use the following code to load blob into database.
    if the file is in the server-side, it can work, but if it in the client-side, it said that the system cannot find the file. i think it only will search the file is in the server-side or not, it will not search the client-side.
    how can i solve it without upload the file to the server first, then load it into database??
    try
    ResultSet rset = null;
    PreparedStatement pstmt =
    conn.prepareStatement ("insert into docs values (? , EMPTY_BLOB())");
    pstmt.setInt (1, docId);
    pstmt.execute ();
    // Open the destination blob:
    pstmt.setInt (1, docId);
    rset = pstmt.executeQuery (
    "SELECT content FROM docs WHERE id = ? FOR UPDATE");
    BLOB dest_lob = null;
    if (rset.next()) {
    dest_lob = ((OracleResultSet)rset).getBLOB (1);
    // Declare a file handler for the input file
    File binaryFile = new File (fileName);
    FileInputStream istream = new FileInputStream (binaryFile);
    // Create an OutputStram object to write the BLOB as a stream
    OutputStream ostream = dest_lob.getBinaryOutputStream();
    // Create a tempory buffer
    byte[] buffer = new byte[1024];
    int length = 0;
    // Use the read() method to read the file to the byte
    // array buffer, then use the write() method to write it to
    // the BLOB.
    while ((length = istream.read(buffer)) != -1)
    ostream.write(buffer, 0, length);
    pstmt.close();
    // Close all streams and file handles:
    istream.close();
    ostream.flush();
    ostream.close();
    //dest_lob.close();
    // Commit the transaction:
    conn.commit();
    conn.close();
    } catch (SQLException e) {

    Hi,
    Without some more details of the configuration, its difficult to know
    what's happening here. For example, what do you mean by client side
    and server side, and where are you running the upload Java application?
    If you always run the application on the database server system, but can't
    open the file on a different machine, then it sounds like a file protection
    problem that isn't really connected with the database at all. That is to
    say, if the new FileInputStream (binaryFile) statement fails, then its not
    really a database problem, but a file protection issue. On the other hand,
    I can't explain what's happening if you run the program on the same machine
    as the document file (client machine), but you can't write the data to the
    server, assuming the JDBC connection string is set correctly to connect to
    the appropriate database server.
    If you can provide some more information, we'll try to help.
    Simon
    null

  • How can i execute a SAP function from destop in froeground mode?(JCO)

    Hi Experts,
    I faced a problme during my work.
    i need a programme log on a SAP system and then execute a function from my windows desktop. however i need this function to be executed in front end because there are someting need to be poped up.
    i am using Jco but it seems it only support executing a RFM in background mode?
    how can I do?
    Many thanks!!
    Useful answers will be awarded!
    Cliff

    Hi Apurva,
    thanks for your reply.
    the situation is like that. my function is to call catt/ecatt which need sapgui popup sometimes..
    i test the fuction inside R3 system which works fine however when i use JCO to call it from desktop error shows..
    log infomation is useful however in this situation popup sapgui is very important.
    the idea way is JCO call SAPGUI in destop and execute my fuction automatically:)
    Many thanks for your replies!
    Cliff

  • How can i execute a SAP function from destop in froeground mode?

    Hi Experts,
    I faced a problme during my work.
    i need a programme log on a SAP system and then execute a function from my windows desktop. however i need this function to be executed in front end because there are someting need to be poped up.
    i am using Jco but it seems it only support executing a RFM in background mode?
    how can I do?
    Many thanks!!
    Useful answers will be awarded!
    Cliff

    Does any one can help?

  • How can I change file to Podcast from Music or Audiobook?

    I am frustrated with how some of my files are automatically categorized. For example, I listen to podcasts of This American Life on my iPod. If I purchase them, they show up as Audiobooks. If I get them from the podcast, they show up under Podcasts. If I get them from CD, they show up as music. How can I move them so they are all in the same place. I thought maybe I could drag them, but that doesn't work.

    Thanks! I didn't know about that. Unfortunately, "Podcast" isn't an option. So if it's something I normally get as a podcast, but occasionally get from another source, is there a way to put the files under Podcast? Or do I need to move it all to Music in order to have it consolidated?

  • How can I execute an IE browser window from within my java application?

    I am programming a java application that requires me to execute a browser application and point to a specific web site. How can I do this? I cannot seem to find any examples on the web.

    Hi Heals,
    This forum is for discussing Measurement Studio for Visual Basic and is not really a good place to ask general purpose Java questions. I suggest searching one of the comp.lang.java.* newsgroups at http://groups.google.com/.
    Off the top of my head, though, I would say take a look at the Runtime.exec method.
    - Elton

  • How to save CD files to disk from within Flash?

    Hi.
    Is there any way I can copy files from a swf in a CD ROM to
    users computer?
    Some kind of "save to..." from within flash... ?
    Maybe I can explain better what I need to do:
    I have an external .swf, loaded into an .EXE.
    In the .swf, I need to put buttons to downloads of wallpapers
    and stuff.
    This is where my troubles start...
    tks for your time.

    pedrosantos.dsgner wrote:
    > Hi.
    > Is there any way I can copy files from a swf in a CD ROM
    to users computer?
    > Some kind of "save to..." from within flash... ?
    >
    > Maybe I can explain better what I need to do:
    > I have an external .swf, loaded into an .EXE.
    > In the .swf, I need to put buttons to downloads of
    wallpapers and stuff.
    >
    try
    http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context= LiveDocs_Parts&file=00002210.html
    or 3rd party tools like Jsystem from
    http://www.flashjester.com/?section=tricks_jtools_jsystem
    Regards
    Urami
    Happy New Year guys - all the best there is in the 2006
    <urami>
    http://www.Flashfugitive.com
    </urami>
    <web junk free>
    http://www.firefox.com
    </web junk free>

Maybe you are looking for