Problem met when call external exe in jar.

hi all,
in my java project, i call an external exe . i met a problem that sometimes the exe is not fully finished. How could i confirm that the exe is finished before i start to use the output of this exe.
i use following code to call the external exe:
Runtime.getRuntime().exec(command).

Hi Avm,
thanks very much.
The simplest answer is that
getRuntime().exec(command).waitFor() will help you.
But besides of sync there are number of other
potential problems with Runtime.exec
Good examples and description there is here:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-
traps.html

Similar Messages

  • How can I call external exe in java

    Hi ,
    Is It Possible to call external exe in java.
    I read Runtime.exe("some exe") but actually my exe expects some input to process for that how can i pass the input to my exe and how can get the response from exe to my java class.
    any sample code is welcome.
    Thanks
    Babu H

    example
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.io.*;
    public class RuntimeExample extends JFrame {
        private JTextArea textArea;
        private JTextField textField;
        private PrintWriter writer;
        public RuntimeExample()
            init();
            initProcess();
        public void init()
            textArea = new JTextArea(20, 80);
            textArea.setEditable(false);
            textField = new JTextField(30);
            textField.addKeyListener(new KeyAdapter()
                public void keyPressed(KeyEvent event) {
                    if (event.getKeyCode() == KeyEvent.VK_ENTER)
                        if (writer != null)
                            textArea.setText("");
                            writer.print(textField.getText() + "\r\n");
                            writer.flush();
                            textField.setText("");
            Container container = getContentPane();
            JScrollPane scrollPane = new JScrollPane();
            scrollPane.setViewportView(textArea);
            container.add(scrollPane, BorderLayout.CENTER);
            container.add(textField, BorderLayout.SOUTH);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            pack();
            textField.grabFocus();
            setVisible(true);
        public static void main(String[] args) {
            new RuntimeExample();
        public void initProcess()
            Runtime rt = Runtime.getRuntime();
            try
                //Process p = rt.exec(new String [] {"cmd", "/C", textField.getText()});
                //textArea.setText("");
                //textField.setText("");
                Process p = rt.exec("cmd");
                writer = new PrintWriter(p.getOutputStream());
                Thread thread1 = new Thread(new StreamReader(p.getErrorStream()));
                Thread thread2 = new Thread(new StreamReader(p.getInputStream()));
                thread1.start();
                thread2.start();
                System.out.println("Exit Value = " + p.waitFor());
            catch (Exception ex)
                textArea.append(ex.getMessage());
                ex.printStackTrace();
        public class StreamReader implements Runnable
            InputStream is;
            public StreamReader(InputStream is)
                this.is = is;
            public void run()
                try
                    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
                    String data;
                    while ((data = reader.readLine()) != null)
                        textArea.append(data + "\n");
                    reader.close();
                catch (IOException ioEx)
                    ioEx.printStackTrace();
    }you can pass input to the exe by using getOutputStream() from Process and get the output from getInputStream() from Process

  • Problem meet when call exe in java.

    hi all,
    in my java project, i call an external exe . now the problem is that sometimes the exe is not fully finished. How could i confirm that the exe is finished before i start to use the output of this exe.
    i use following code to call the external exe:
    Runtime.getRuntime().exec(command).

    Hi,
    Please post this to an appropriate forum . this forum is exclusively related to creator
    MJ

  • Error when calling  external  DLL  function.

    When calling a function in Oracle, the error happens
    ORA-28575: '... error RPC connection to external procedures'
    code:
    create or replace library LibFunctions as 'c:\MyDLL.dll';
    grant all PRIVILEGES on LibFunctions to public;
    create or replace
    FUNCTION Max(num1 in number, num2 in number) RETURN number IS
    EXTERNAL LIBRARY LibFunctions
    NAME "Max"
    LANGUAGE C;
    grant all PRIVILEGES on Max to public;
    obs. Dll was created in Pascal.
    What can this error?
    tks,
    Mauricio
    Edited by: user13794390 on 19/01/2011 06:29

    It's been a while since I used extproc. Anyway, it listener.ora make sure extproc is added. I'll assume you are on Unix:
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ENVS = "EXTPROC_DLLS=ANY,LD_LIBRARY_PATH=proper-directory-list")
    (ORACLE_HOME = path-to-oracle-home)
    (PROGRAM = extproc)
    ) SY.

  • Can you call external exe file from Flex Air Application like notepad.exe

    Im trying to make my Air Application open an External exe file anyone know if this can be done?

    Hi,
    If you want to share code between a flex app and AIR, you
    could isolate the common bits as a swc file and link to the swc
    from both the flex and air project.
    Also, you could have the flex mxml file and air mxml file
    load the same module (which has the same stuff as your original
    flex application) using ModuleLoader.
    Or, you could even load the swf of your flex application
    using SWFLoader in your air mxml file.
    Basically, check out creating flex libraries, modules and
    runtime loading of swfs.

  • Problem when calling external program

    Hi,
    I have a strange problem and no more idea how to solve it.
    What I do:
    In Java I call an external Fortran-exe with Runtime.getRuntime().exec(...) This Fortran program creates 4 files.
    What I get:
    One of the 4 files is incomplete, the first few lines are missing.
    What makes me wonder:
    When I take the exec-statement to the commandline and let it run there, everything is fine and the files contain all the info I need. All the 4 files are correct then.
    What I also tried:
    I tried to copy the (incomplete) file within Fortran. That means when I call the Fortran program I get 2 identical files then but with different filenames. Doing so on the commandline everything is fine again. But again, the same commandline String called in the exec in my Java program it is getting worse: The formerly incomplete file is empty now with 0 bytes.
    Even if I wait for the process to finish does not help.
    I do not understand it any more and would really like to know what happens there, why, and what can I do to avoid it or to get my complete output files. What does Runtime.getRuntime().exec(myString) do different than when I take the myString on the commandline?
    Any hints welcome.
    TIA

    Hi,
    unfortunately this does not help. I have already about 15 Fortran programs running this way which work accurately. So a possible problem with output stream does not look reasonable to me in this case.

  • Problems met when upgrading APEX within Oracle XE to APEX 4.0

    Hi,
    When I tried to upgrade APEX within Oracle XE to APEX4.0, I met problems.
    Here's how I did (I'm on windows 7):
    1. Downloaded the latest oracle xe database (based on 10.2.0.1)
    2. Installed it by running the setup.exe. The installation was success. And I can login to the database.
    3. Downloaded latest application express (4.0)
    4. Unzipped it into d:\
    *5. Run sqlplus as sysdba, and run the install script: '@d:\apex\apexins.sql SYSAUX SYSAUX TEMP /i/'*
    When doing this step, the sqlplus window closed quickly. I'm not sure whether this step is success as I can not find the log file in 'd:\apex' folder*
    *6. I continued to run sqlplus as sysdba again, and run the load images script: '@d:\apex\apxldimg.sql d:\'*
    When doing this step, some error messages in sqlplus window, saying:*
    SQL> @D:\apex\apxldimg.sql D:\
    PL/SQL procedure successfully completed.
    old   1: create directory APEX_IMAGES as '&1/apex/images'
    new   1: create directory APEX_IMAGES as 'D:\/apex/images'
    Directory created.
    if wwv_flow_utilities.db_version_is_at_least('11') then
    *+
    ERROR at line 32:
    ORA-06550: line 32, column 25:
    PLS-00302: component 'DB_VERSION_IS_AT_LEAST' must be declared
    ORA-06550: line 32, column 3:
    PL/SQL: Statement ignored
    PL/SQL procedure successfully completed.
    if wwv_flow_utilities.db_version_is_at_least('11') then --11g onl
    *+
    ERROR at line 15:
    ORA-06550: line 15, column 25:
    PLS-00302: component 'DB_VERSION_IS_AT_LEAST' must be declared
    ORA-06550: line 15, column 3:
    PL/SQL: Statement ignored
    Commit complete.
    timing for: Load Images
    Elapsed: 00:00:00.29
    Directory dropped.
    SQL>
    *7. Then I kept on running the change password script: '@d:\apex\@apxchpwd.sql'*
    When doing this step, some error messages in sqlplus window, saying:*
    SQL> @D:\apex\apxchpwd.sql
    Enter a value below for the password for the Application Express ADMIN user.
    Enter a password for the ADMIN user              []
    ERROR:
    ORA-01435: user does not exist
    +...changing password for ADMIN+
    wwv_flow_security.g_security_group_id := 10;
    *+
    ERROR at line 3:
    ORA-06550: line 3, column 5:
    PLS-00201: identifier 'WWV_FLOW_SECURITY.G_SECURITY_GROUP_ID' must be declared
    ORA-06550: line 3, column 5:
    PL/SQL: Statement ignored
    ORA-06550: line 4, column 5:
    PLS-00201: identifier 'WWV_FLOW_SECURITY.G_USER' must be declared
    ORA-06550: line 4, column 5:
    PL/SQL: Statement ignored
    ORA-06550: line 5, column 5:
    PLS-00201: identifier 'WWV_FLOW_SECURITY.G_IMPORT_IN_PROGRESS' must be declared
    ORA-06550: line 5, column 5:
    PL/SQL: Statement ignored
    ORA-06550: line 8, column 23:
    PL/SQL: ORA-00942: table or view does not exist
    ORA-06550: line 7, column 15:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 13, column 32:
    PLS-00364: loop index variable 'C1' use is invalid
    ORA-06550: line 12, column 9:
    PL/SQL: Statement ignored
    ORA-06550: line 19, column 5:
    PLS-00201: identifier 'WWV_FLOW_SECURITY.G_IMPORT_IN_PROGRESS' must be declared
    ORA-06550: line 19, column 5:
    PL/SQL: Statement ignored
    Could anybody help me on this problem ? Thanks a lot.

    Hi,
    I assume your install did fail.
    As you can not find log file I assume it is something relating folder permissions.
    I do not know folder these permissions work in Windows.
    But try give everybody read/write permission to your d:\apex.
    Then try again
    Regards,
    Jari
    Edited by: jarola on Mar 11, 2011 3:58 PM
    And change your working directory to d:\apex before you run scripts.
    Then you can run just
    @apexins SYSAUX SYSAUX TEMP /i/And see this guide
    http://www.oracle.com/technetwork/developer-tools/apex/upgrade-apex-for-xe-154969.html

  • Extproc crashes when calling external routine

    Can anyone point me to documentation on the causes of extproc.exe crashing when trying to invoke an external procedure? The standard documentation set isn't too helpful for debugging such a problem.
    I have been able to call one external procedure. With two others, I always get an extproc crash with (I believe) an access violation.
    The routines I am trying to call are 3rd-party, so I do not have the ability to view their source, though I do have the list of parameters and the sizes and types.
    What I am hoping to find somewhere is a list of the kinds of things that cause extproc to crash so I can see if any of them are likely culprits in my situation.
    Thanks,
    Bruce Merkle

    Have you tried calling into the dll that CVI calls directly from TestStand?  I am curious to know if this also crashes.
    I am also curious to know if there are any path references in the dll that is called by the CVI program.  If so are they relative, or absolute paths?
    I ask because one of the possibilities is that relative paths are being used to specify a path from the location of the code that is called, and they are not working because the current working directory is being specified by TestStand, and the paths are not relative to the working directory given by TestStand.
    Jensen
    National Instruments
    Applications Engineer

  • How to handle spaces when calling javaw.exe or java.exe

    Hi guys, I'm in the process of releasing my application.
    My application need to make this system call on Windows.
    C:\Program Files\MySoftware\javaw.exe -jar C:\Program Files\MySoftware\myJar.jar C:\Program Files\MyDocs\MyArgumentFile
    this 'Program Files' for after the javaw.exe call: C:\Program Files\MySoftware\myJar.jar causes a problem because javaw.exe consider C:\Program as it's first argument and thus crash.
    I wonder what to do with this. I don't want to change it to C:\MySoftware since it looks unprofessional.
    A cup of Java, cheers

    yawmark wrote:
    I wonder what to do with this.Quotation marks.
    ~Right, every shell I can think of allows you to use quotation marks around a set of any characters that you want to be treated as one token. Note that this feature is a function of the shell you're using, not necessarily the system API. Also, many shells treat single quotes and double quotes differently, though they usually both accomplish the purpose of grouping what they contain into a single token.

  • Configurations to be done when calling external web service

    Hi,
    Do we need to do any configurations in SAP when we want to call any external web service from sap.
    I have created a proxy based on URL (WSDL) and I have searched this consumer proxy in soamanager transaction.
    I found the result and when I click on Apply Selection it is giving some errors in the soamanager screen at the top.
    The error is " Error : Internal error" . When I click this error link no error text is available.
    How to check the errors displayed in soamanager.
    Can anyone explain on how to resolve this issue. Once these errors are rectified then only I can create a logical port.

    You have problems with authorizations when you try to create logical port.

  • FRM-40734 when calling external DLL Function from Forms 6

    Even though some answers were given to my previous help request ("Again: Forms 6 and user-defined data types") I wasn't able to solve the problem of passing a parameter of an user-defined type to an external DLL function residing in the SECURSIGN.DLL library (the closest solution was to declare that "composite" parameter using the ROWTYPE clause referencing a custom-made table created just for the sake of defining that perticular datatype).
    So I concentrated on SECURSIGN.DLL functions using more trivial data types, like a function requiring just four character strings as parameters.
    I generated the necessary PL/SQL support using the FFI.
    I discovered that also the simplest calls to external functions fail at runtime with the generic error FRM-40734.
    I located the error: it happens just at the moment of calling the function from within the FFI-generated package body. Before that, the DLL is loaded with no problem, the function is correctly registered, and a function handle is regularly returned.
    As long as I can regularly issue the very same call with the very same parameters from Visual Basic, I can't understand what's going wrong (ALL the needed DLL are in the same directory as the FMB/FMX forms).
    I will greatly appreciate any help that You may be able to provide.

    I have noticed just now that a dump file having a name like ifrun60_dump_299, is generated by FORMS every time I issue the aborted call to the foreign function.
    Inside the form dump file, apart from useless info like Registers and so on, the message:
    "Could not find Module32First"
    By a FILE/FIND/CONTAINING TEXT I searched all the DLLs, and I noticed that Module32First is a routine that can be found within each of the following DLLs:
    Cl32
    d2kwut32
    d2kwut60
    I tried to load those DLLs along with SECURSIGN.DLL by modifying the PROCEDURE LoadLibrary into the FFI-generated PLL code, and I have apparently no problem in loading all the DLLs that I wish, but the error persists, and that dump file is constantly generated, always looking for the "Module32First" routine.
    How can I avoid all that mess and the FRM-40734 error??

  • Contents in the parameters have been shifted when calling external rfc

    Dears,
       when i use    ' call <FM name> destination <destination name> '
    the contents of paramters are shifted when reaching .net RFC server .
    and when i transport my program to QAS server, it is ok... all the seting of program and destination are the same .  .net server use SAP connector to communicate with SAP
      any one encounter such problem ? what maybe the reason ?
    BR.

    Do not worry. It is probably a permission you should ignore, but you should check that the permission appears in this site > http://support.apple.com/kb/TS1448?viewlocale=en_US&locale=en_US

  • EjbCreate not completing when calling into third party JAR ?

    Hi
    Are there any limitations/restrictions on calling out to a third-party library within an ejbCreate method of a stateless session bean.
    I've set <initial-beans-in-free-pool> to 1 so that when I deploy the bean ejbCreate is invoked, but only the first System.out appears. The weblogic console shows the EJB deployment status as available, no stack traces of exceptions are shown.
       public void ejbCreate() {
            try {
                System.out.println(new Date() + " EJB XTestBeam ejbCreate invoked");
                searcher = new SearcherService();
                System.out.println(new Date() + " EJB XTestBean created SearchService " + searcher);
                System.out.println(new Date() + " EJB XTestBean ejbCreate completed ok");
            } catch (EJBException e) {
                e.printStackTrace();
                throw e;
            } catch (RuntimeException e) {
                e.printStackTrace();
                throw e;
            } catch (Exception e) {
                e.printStackTrace();
        }The environment is WLS 8.1 SP4, W2K, HotSpot Client VM 1.4.2_05.
    Rgs
    Erik

    Thanks chrisswhite,
    I should have mentioned that I tried this too and it didn't solve the problem. You're right though, I should be compiling with -fPIC anyway.
    Jon

  • Close portal (session) when calling external url

    Hi there,
    does anyone know if its possible and if yes, how to automatically close a portal session when (or after) calling an external url from within the portal.
    Cheers
    Walter

    i think you can write a script for this using EPCF.
    Shankar

  • Problem facing when calling a JAX WS WSDL

    Hi,
    I have a simple JAVA WS , deployed in a server and I want to call it from ODI , the JAVA Class takes some inputs as input Parameter and writes the data into the DB.
    I didn't use any explicit XSD for designing the WS, WS has it own inline schema.
    definitions targetNamespace="http://ws.test.com/" name="TestWSService"><types><xsd:schema><xsd:import namespace="http://ws.test.com/" schemaLocation="http://localhost:7001/Test-context-root/TestPort?xsd=1"/></xsd:schema></types>
    When I am using clicking on Connect to WSDL from OdiInvokeWebService tool from the Advance Editor, it is giving an error as ODI-20362:Couldn't connect to web Service, In the detailed description it is showing as
    "This URL does not point to a valid WSDL"
    I am not getting why I am getting such error, any help is highly appreciable.
    Thanks.

    Hi ,
    Can anyone pls help me.
    Inspite of changing proxy information in its preference dialog of ODI still I am getting the same error when trying to invoke a JAX_WS wsdl with inline schema.
    ODI-20362: Couldn't connect to web Service.
    In the detailed part I am getting as follows:
    com.sunopsis.wsinvocation.SnpsWSInvocationException: com.sunopsis.wsinvocation.SnpsWSInvocationException: This URL does not point to a valid WSDL
        at com.sunopsis.wsinvocation.client.WebServiceFactory.getParserIstance(WebServiceFactory.java:95)
        at com.sunopsis.wsinvocation.client.WebServiceFactory.getParserIstance(WebServiceFactory.java:126)
        at com.sunopsis.graphical.wsclient.RequestWsPane$17.doInBackground(RequestWsPane.java:1691)
        at com.sunopsis.graphical.tools.utils.swingworker.SwingWorker$1.call(SwingWorker.java:240)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:139)
        at com.sunopsis.graphical.tools.utils.swingworker.SwingWorker.run(SwingWorker.java:279)
        at oracle.ide.dialogs.ProgressBar.run(ProgressBar.java:656)
        at java.lang.Thread.run(Thread.java:662)
    Caused by: com.sunopsis.wsinvocation.SnpsWSInvocationException: This URL does not point to a valid WSDL
        at oracle.odi.wsinvocation.client.impl.jaxws.OdiJaxwsParserImpl.setWsdlUrl(OdiJaxwsParserImpl.java:132)
        at com.sunopsis.wsinvocation.client.WebServiceFactory.getParserIstance(WebServiceFactory.java:89)
        ... 8 more
    Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=OTHER_ERROR: Error importing schemas: java.io.IOException: Unable to parse schema at 'http://172.18.41.47:7001/GenericErrorHandlerWSApp-GenericErrorHandlerWS-context-root/ErrorHandlerWSPort?xsd=1': Expected 'EOF'.
        at oracle.j2ee.ws.wsdl.extensions.schema.SchemaSerializer.unmarshall(SchemaSerializer.java:76)
        at oracle.j2ee.ws.wsdl.extensions.ParseUtils.createExtensibilityElement(ParseUtils.java:112)
        at oracle.j2ee.ws.wsdl.xml.WSDLReaderImpl.parseTypes(WSDLReaderImpl.java:1505)
        at oracle.j2ee.ws.wsdl.xml.WSDLReaderImpl.parseDefinition(WSDLReaderImpl.java:790)
        at oracle.j2ee.ws.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:707)
        at oracle.j2ee.ws.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:656)
        at oracle.j2ee.ws.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:648)
        at oracle.odi.wsinvocation.client.impl.jaxws.OdiJaxwsParserImpl.setWsdlUrl(OdiJaxwsParserImpl.java:128)
        ... 9 more
    Caused by: java.io.IOException: Unable to parse schema at 'http://172.18.41.47:7001/GenericErrorHandlerWSApp-GenericErrorHandlerWS-context-root/ErrorHandlerWSPort?xsd=1': Expected 'EOF'.
        at oracle.j2ee.ws.wsdl.extensions.schema.SchemaSerializer.readSchemaFile(SchemaSerializer.java:186)
        at oracle.j2ee.ws.wsdl.extensions.schema.SchemaSerializer.loadReference(SchemaSerializer.java:138)
        at oracle.j2ee.ws.wsdl.extensions.schema.SchemaSerializer.processImportIncludeRedefine(SchemaSerializer.java:108)
        at oracle.j2ee.ws.wsdl.extensions.schema.SchemaSerializer.unmarshall(SchemaSerializer.java:73)
        at oracle.j2ee.ws.wsdl.extensions.ParseUtils.createExtensibilityElement(ParseUtils.java:115)
        at oracle.j2ee.ws.wsdl.xml.WSDLReaderImpl.parseTypes(WSDLReaderImpl.java:1505)
        at oracle.j2ee.ws.wsdl.xml.WSDLReaderImpl.parseDefinition(WSDLReaderImpl.java:790)
        at oracle.j2ee.ws.wsdl.xml.WSDLReaderImpl.readWSDL(WSDLReaderImpl.java:708)
        ... 12 more

Maybe you are looking for

  • Velocity Displcement Calibration for Sound and Vibration Tool Kit

    Hello Guys, I have been working on sound and vibration tool kit recently. I'm taking input from sound port of PC by signal generator and taking single and double Integration for velocity and displacement resp. I want to check the correctness of the v

  • Is there a way to change font size in incoming email messages?

    In the Mail preferences I see options for changing fonts and sizes for composing email, but is there a way to control incoming font sizes? Some emails for some reason show up in very tiny fonts when they come into my Mail program thanks nick

  • Extremely Bizarre Flicker (not interlacing)

    i have footage that i'm trying to export as a quicktime movie but under different encoding. right now i'm trying to export using cinepack or mp4 and with both the product i get flickers on only the edit points. it's as if all the individual segments

  • Repainting a content pane

    I'm having trouble repainting the contentPane of the parent Container in my GUI app. The application sets a new ContentPane occasionally, but when this happens, the new contentpane does not appear unless I resize the window of the application, or do

  • Qualification catalog

    Hi expert, I am a beginner with  SAP CRM 2007. I have created a qualification catalog in the SAP GUI with a structure : for example : SAP CRM Module Service In the WebUI, when I want to assign a qualification to an employee I see only the first level