Process (.exe) run from java

Hi all,
  I need to run a ".exe" from my .java file. I have developed a sample Swing GUI application that calls a ".exe" from my program. The application contains a dialog box. The dialog contains a text box and a button. When user will enter some number in the text box and hits the button a ".exe" will be called. That ".exe" in turn will perform a DB activity, fire some sql queries and insert some data into the database. The 32 bit ".exe" is built in Visual studio and developed by C++.
The problem is that when I am entering some number and pressing the button, the ".exe" file is invoked and the process starts running, but I could not be able to see the data that is inserted into the database after the tested time of process run. I could see the data in table only when I quit my java swing application by closing the dialog.
What I mean by tested time of process run is that, I have tested the ".exe" separately by running the same from a batch file. That is running fine and data is inserted into database like a charm. I want the same from java code.
Programmatically what I did to run the .exe is as follows:
String[] cmdArray = new String[3];
cmdArray[0] = "testRun.exe";
cmdArray[1] = "some args";
cmdArray[2] = "some args";
Process process = Runtime.getRuntime().exec(cmdArray,null);
It will be of great help if anybody can figure out where the actual problem is.
My program is not even multithreaded. The whole thing is written inside the main thread itself as in normal case.
Thanks in Advance.....

{quote}
The problem is that when I am entering some number and pressing the button, the ".exe" file is invoked and the process starts running, but I could not be able to see the data that is inserted into the database after the tested time of process run. I could see the data in table only when I quit my java swing application by closing the dialog.
{quote}
The process must issue a COMMIT before the data will be visible to ANY other session.

Similar Messages

  • Exe running from java fails to get user input .Help me...

    I have an DOS based exe.It just asks for input for a number from the user and prints the number it gtes.
    When I try to execute this program from Java with the following code
    import java.lang.Runtime;
    import java.lang.Process;
    import java.io.*;
    public class runtimetest     {
         public static void main(String[] args)     throws Exception {
              Runtime rt = Runtime.getRuntime();
              Process p = rt.exec("myExe");
    nothing happens.Thatis It doesnot ask for the input .and I am just unable to know whether its running or not.
    What could be wrong?
    What is the other means to tun the DOS based exe that accepts user inputs , from Java.
    Plz help me as I am in urgent need.
    Aathi

    try this
    Runtime r = Runtime.getRuntime();
              Process p = null;
              try
                   System.out.println("Exe will be called");
                   p = r.exec("cmd.exe /c start c:/ur exe path ");
                   p.waitFor();
              catch (Exception e)
                   e.printStackTrace();
              }

  • .exe file from java

    Hi all !!!
    Is it possible to run a *.exe file from java.....
    if yes how??
    if no why not??
    regards
    ad

    Yes. It's possible. One of the Runtime.exec() methods are probably what you want:
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
    You can't instantiate a Runtime object, so you'll need to call it up by:
    Runtime.getRuntime()
    For example, if you want to run the Calculator in Windows, try:
    Runtime.getRuntime().exec("calc");

  • I wants to call .Exe file from Java Programme

    I wants to call .Exe file from Java programme. Please give answer with example. This very urgent. Help me

    hi
    u can use Runtime.exec() method in java.lang package
    to execute exe files
    regards
    pnp

  • Running .EXE file from Java

    Do you know, how run an .exe file, for example Internet Explorer or other program, from Java application?
    It's very important for me.

    Too run external program and pass string arguments see class java doc
    of java.lang.Runtime method exec . You see online or download or
    rename src.jar to s.zip EXTRACT and see
    exec
    public Process exec(String[] cmdarray,
    String[] envp)
    throws IOException
    Executes the specified command and arguments in a separate process with the
    specified environment.
    This is a convenience method. An invocation of the form exec(cmdarray, envp)
    behaves in exactly the same way as the invocation exec(cmdarray, envp,
    null).
    Parameters:
    cmdarray - array containing the command to call and its arguments.
    envp - array of strings, each element of which has environment variable
    settings in the format name=value, or null if the subprocess should inherit
    the environment of the current process.
    Returns:
    A new Process object for managing the subprocess
    Throws:
    SecurityException - If a security manager exists and its checkExec method
    doesn't allow creation of the subprocess
    IOException - If an I/O error occurs
    NullPointerException - If cmdarray is null, or one of the elements of
    cmdarray is null, or one of the elements of envp is null
    IndexOutOfBoundsException - If cmdarray is an empty array (has length 0)
    See Also:
    ProcessBuilder
    getRuntime
    public static Runtime getRuntime()
    Returns the runtime object associated with the current Java application.
    Most of the methods of class Runtime are instance methods and must be
    invoked with respect to the current runtime object.
    Returns:
    the Runtime object associated with the current Java application.

  • Running exe files from java applications

    Hello All,
    Is it possible to run executable files from java applications?
    I need to run an exe file on the client from the server machine, the exe could reside on either the server or any other machine on the LAN. Is it possible to specify the path of where the exe resides, and run it on a client machine?

    HI,
    I tried to launch a MS Word application using runtime.exec but it gives me some problem
    The foll. code to launch a txt file using notepad works.
    Runtime rt = Runtime.getRuntime();
    String[] callAndArgs = {"notepad.exe","C:\\coo7\\wizard.txt"};
    Process child = rt.exec(callAndArgs);
    However, oif I try to launch a MS Word application, it asks for the entire path of WINWORD.exe, (unlike just specifying notepad.exe as the first argument in String[] callAndArgs) and this can vary from one machine to another.. how do I get around this?
    The foll. code snippet works but the complete path of where WINWORD.exe might be installed on any machine, is not fixed:-(
    Runtime rt = Runtime.getRuntime();
    String[] callAndArgs = {"C:\\Program Files\\Office\\Office10\\WINWORD.exe","C:\\coo7\\wizard.doc"};
    Process child = rt.exec(callAndArgs);
    Any idea/suggestions pls..

  • Run a EXE 'safely' from java

    I want to run a EXE from java code. I did it using Runtime.getRuntime.exec("")...
    but is there a way to prevent the EXE from modifying the files already on the system...I mean the EXE is from a untrusted source......so it may do some malicious activities...is there a way I can stop the EXE from modifying the contents of other files......
    Thanks.

    The people here are volunteers. They post answers for whatever reasons.
    but is there a way to prevent the EXE from modifying the files already on the system...That question has nothing to do with java. Nor really any programming language for that matter. It is an OS question and one that is specific to the OS.
    When an executable is called in java the OS creates another application. Just as if you ran it yourself.
    So the question is whether your OS allows that.
    Given that you said "exe" I presume you mean windows. And that limits your answer to windows users. So you would need a windows user created, which only has read permissions on the system. Then you figure out a windows command that lets you run an application as another user. I am not sure that such an app comes with windows but it if doesn't it can be coded - in C/C++ not java.

  • Exe run during java process

    What are the names of exes' or other processes which are run during execution of any Java program on any Computer System which we can trace into Task Manager..
    Please reply

    {quote}
    The problem is that when I am entering some number and pressing the button, the ".exe" file is invoked and the process starts running, but I could not be able to see the data that is inserted into the database after the tested time of process run. I could see the data in table only when I quit my java swing application by closing the dialog.
    {quote}
    The process must issue a COMMIT before the data will be visible to ANY other session.

  • Specify a exe running from certain directory from java program

    Hi there,
    I had a java program, which will spawn some child process to run vb COM;
    what I wanted to do: have a child process start the COM from a specific diretory?
    IS there any way to do it from Java, like shell programming?
    Thanks

    I do all my portable shell stuff now in ant.. http://jakarta.apache.org/ant/
    it is an XML driven java script for doing builds.. but it can be used for shell scripting.
    They are also some java scripting languages like jPython but i am not very familiar with them.
    u can also get Cygwin and write unix shell scripts. www.cygwin.com
    hope this helps

  • Running an exe file from java

    Hi , can anyone tell me how to run an exe file from my java program. the exe is in the same directory as my java files . When i click on a button i want to put something in the actionPerformed() method which will launch the exe file - prog.exe
    Hope someone can help me.
    Thanks Jim

    Hi !
    Look at the RunTime class...

  • Problem in Running EXE file from Java

    Hello Friends,
    I am calling an EXE program from my JSP page using Runtime.exec() method. The exe file simply reads a file and writes the content into another file (like copying a file). Now if I am providing fully qualified path to both source and destination files, then it runs absolutely fine. However, if i don't mention file path (only fine name is there), it creates output file in System32 folder and the resultant file doesn't contain any data.
    I am providing the source for the EXE file.
    ==============
    Source 1 (with fully qualified path name)
    #include <stdio.h>
    #include <fstream.h>
    #include <iostream.h>
    #include <string.h>
    #include <stdlib.h>
    void write_temp_file1(char *);
    void main()
    char * myTempPath=NULL;
    myTempPath=(char *)calloc(100,sizeof(char));
    strcpy(myTempPath,"D:\\temp\\tempFile.txt");
    write_temp_file1(myTempPath);
    myTempPath=NULL;
    void write_temp_file1(char * fileName)
    // first read the file and write another file with same content
    char * line1=NULL;
    char * line2=NULL;
    char * line3=NULL;
    line1=(char *)calloc(100,sizeof(char));
    line2=(char *)calloc(100,sizeof(char));
    line3=(char *)calloc(100,sizeof(char));
    ifstream inf;
    inf.open(fileName,ios::nocreate);
    inf>>line1;
    inf>>line2;
    inf>>line3;
    inf.close();
    ofstream outf;
    strcat(fileName, "1");
    outf.open(fileName);
    outf<<line1<<endl;
    outf<<line2<<endl;
    outf<<line3<<endl;
    outf.close ();
    ================================
    Scenario 2 (with file name only)
    #include <stdio.h>
    #include <fstream.h>
    #include <iostream.h>
    #include <string.h>
    #include <stdlib.h>
    void write_temp_file1(char *);
    void main()
    char * myTempPath=NULL;
    myTempPath=(char *)calloc(100,sizeof(char));
    strcpy(myTempPath,"my_temp_from_exe.txt");
    write_temp_file1(myTempPath);
    myTempPath=NULL;
    void write_temp_file1(char * fileName)
    // first read the file and write another file with same content
    char * line1=NULL;
    char * line2=NULL;
    char * line3=NULL;
    line1=(char *)calloc(100,sizeof(char));
    line2=(char *)calloc(100,sizeof(char));
    line3=(char *)calloc(100,sizeof(char));
    ifstream inf;
    inf.open(fileName,ios::nocreate);
    inf>>line1;
    inf>>line2;
    inf>>line3;
    inf.close();
    ofstream outf;
    strcat(fileName, "1");
    outf.open(fileName);
    outf<<line1<<endl;
    outf<<line2<<endl;
    outf<<line3<<endl;
    outf.close ();
    ==========================
    Can anyone figure out what could be the problem ? I think there is a problem with Library Path or sort of something like that.
    Please help me.
    -- Niranjan

    providing source code for the EXE program doesn't tell your problem.
    You have to be more specific. What is your problem?

  • Creating win 32 exe files from java class files

    Hi I am using windows 2000.
    I have developed a java swing gui application that has about 10 class files. I downloaded the microsoft sdk for java 4.0 for converting all my class files into a single .exe file. I used jexegen in this SDK to do this process. But when I double click the exe file, it just pops up and closes instantenously without showing my startup frame.
    Can anyone help ?

    There is no Microsoft solution for this until you get J#, change your program
    (J# is a little bit different that java but not much, it's closer to Java than C#)
    and then compile to Win32 .exe.
    For the refrence list of all Java to Native code compilers, check this page:
    http://www.geocities.com/marcoschmidt.geo/jcomp.html#native :
    Different from "normal" compilers (like javac or jikes), native compilers do not create bytecode files
    (.class) that are interpreted by a Java Virtual Machine but native executables (like .exe files on
    Windows). "How do I create an EXE from Java?" is a very frequently asked question in newsgroups
    like comp.lang.java.programmer, native compilers are the answer. Some native compilers are listed
    below, check them out.

  • Can programs run from java that is on web browser

    i have written a program and used autorun to run when a cd is put on but not every body will have java on their computer a firend told me that most people will have java on the web browser that will be able to run the cd is this true or will i have to give download instructions to download jav first. this is obviously not ideal as i want people to be able to run the program by putting the cd in and nothing else.

    1. You can create a Java applet, which is a Java program that runs
    from a web page. It will need to be a signed applet. Your autorun will start the browser with the web page carrying the Java applet.
    I don't think this is optimal.
    2. Search for "embed JRE", which describes how you can supply your
    private JRE with your program. It does not install the JRE, nor does it
    care if one is already installed. I did this many times, there is no problem
    at all, but here I have no idea whatsoever what happens if your JRE originates from write protected media. I guess it should work. Experiment or wait for others to see what they think.

  • Calling exe files from java

    heyy
    can anybody please help me out in calling an exe file using java??
    also i would like to pass parameters tooo.
    i have been trying the following runtime code
    but found no success
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("make.exe 12");
    proc.waitFor();
    int exitVal = proc.exitValue();
    Does anybody havea better soultion???
    Thanks for your time
    Rachit

    Read this article, please http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Determining the name of the jar file running from JAVA

    Hi everyone,
    This is probably a silly question, but how do you determine the name of the jar file running from within the jar file.
    E.g. If I'm running the jar file "Test.jar", then how can I get the String value "Test.jar" from within my program?
    Any help would be appreciated! Thanks:)

    I think that you can use the solution above to get the jar file resources associated with a particular jar file, and then use the JarFile class to get a manifest of whats in there, and then find your class?
    This is only off of the top of my head, and I haven't tested it. Let me know if it works

Maybe you are looking for

  • Unable to delete confirmation (GR)

    Hi, I am having a very strange problem while deleting one of the confirmation. The error reads "Interface data contains error". Could you please help what could be the problem ? Thanks and regards, Jaya

  • API for sending an SMS

    Is there an API for sending an SMS from a Mac to a cellphone, similar to what iChat does

  • ABAP to CRM

    Hi  all, Am an ABAPer. Please tell me  what exact ABAP(BADi,BAPI,Smart form,Idoc,Transaction,Reports,Dynpro etc) required for CRM technical. Also with dominant presence of SIBEL is it correct to move into SAP CRM Thanks.

  • Photoshop elements 12 stopped working after swapping mainboard

    Hi everybody! On a Win 7 Pro PC the PSE 12 Photo Editor stopped working after swapping the defective mainboard. I tried uninstall and reinstall as admin, with disabled security software. We always get the welcome screen from where you launch organize

  • Problem Publishing Handouts to Word 2003

        I am having a problem publishing from Adobe Captivate 4 to Word 2003.  I have followed all steps to create the file: Open an Adobe Captivate project. Select File > Publish. In the Publish dialog box, select Print. In Project Title, enter the desi