Call external program

Hi.
I am quite new to java and I have this problem...for most of you maybe is very simple.
I have a huge XML document which i have to transform to another xml program.
Every time when i tried something like this:
TransformerFactory tFactory = TransformerFactory.newInstance();
Source xmlSource = new StreamSource(xmlFile);
Source xslSource = new StreamSource(new URL(xslFile).openStream());
Transformer transformer = tFactory.newTransformer(xslSource);
transformer.transform(xmlSource, new StreamResult(new File(xmlOutputFile)));
i got "Out of memory error";
Then i tried usig from the command line: XalanTransform <xml_input_file> <xsl_file> <xsl_output_file> and it worked!!!
Now...i want to know how to do this from my program.....
Thankd in advance!

simple
create a batch file
in that batch file u write for transferting xml same as in command promt
now name it as "a.bat"
call this thru java like this
Runtime r = Runtime.getRuntime();
          Process p = null;
          try
               System.out.println("File calling");
               p = r.exec("cmd.exe /c start c:/a.bat");
               p.waitFor();
          catch (Exception e)
               e.printStackTrace();
          }

Similar Messages

  • How to call external programs?

    I have seen people call external programs through LabVIEW and was curious what functions you could use to do this.
    I'm pretty sure its using one of the ActiveX functions  or maybe 'open application reference .vi'.
    Can anyone tell me (or show me) a quick example of how to open an external program (ie excel,  notepad, etc) programatically
    Cory K
    Solved!
    Go to Solution.

    Cory K wrote:
    Where did they get this:
    Kudos for going from "I don't know to start" to "Let's stump Ben" with only the second post to this thread.
    I either copy it from an example or try to browse to it.
    NOTE:
    If you plan to work with MS ActiveX objects, I found it very helpful to do a custom install of Office and make sure the help files for VBA are loaded. These will at the least give you an idea of what the methods are and what parameters go with each.
    Ben
    Message Edited by Ben on 12-31-2008 11:09 AM
    Message Edited by Ben on 12-31-2008 11:13 AM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Attachments:
    Browse.PNG ‏24 KB

  • To call external program

    I would like to know if exists a way of to call external program in windows ce. I'm using cvm J9.

    I don't know how is configured Windows CE, but Windows ME is MIDP 2.0, and formRequest(URL) do it (but work only since MIDP 2.0).
    It's work, but in my case, i try to add arguments, and it doesn't work with : URL = "/Program Files/MyProg/myProg.exe arg1 arg2". If somebody have found a solution...

  • Call external program in background mode

    Hi,
    I am creating a PO using bapi BAPI_PO_CREATE1 in exit USEREXIT_SAVE_DOCUMENT_PREPARE.
    I dont want to write the code in my exit. Instead I want to write the code in a Z program and call it in my exit.
    My Problem.
    How do I call my z program in my exit so that I can pass internal tables from my exit to the z program. Also I want to schedule the call of my external program for background processing.
    I am trying with SUBMIT ZPROG AND RETURN. But not able to pass an internal table.
    I tried PERFORM BAPI_PO_CREATE IN PRGRAM ZPROG, but in this case not able to schedule it in background.
    Please advise.
    Regards,
    Shobhit

    Hi Rich,
    Im setting runtime error:
    My Code in Exit: (xvbfa is the table which i wanna pass)
    concatenate 'SERVICEPO' sy-datum into l_key.
    export xvbfa = xvbfa
                  to shared buffer indx(st) id l_key.
    My Code in the called program ZMM_SERVICE_PO
    Runtime Errors         CONNE_IMPORT_WRONG_OBJECT_TYPE
    Exceptn                CX_SY_IMPORT_MISMATCH_ERROR
    Date and Time          05.12.2005 21:41:54
    ShrtText
         Error when attempting to IMPORT object "XVBFA".
    What happened?
         Error in ABAP application program.
         The current ABAP program "ZMM_SERVICE_PO" had to be terminated because one of
          the
         statements could not be executed.
         This is probably due to an error in the ABAP program.
         When importing the object "XVBFA", the object in the
         dataset had a different type from the target object in the program
         "ZMM_SERVICE_PO" (object types: field, field string/structure, table).
         table).
    Error analysis
         An exception occurred. This exception will be dealt with in more detail
         below. The exception, assigned to the class 'CX_SY_IMPORT_MISMATCH_ERROR', was
          not caught, which
          led to a runtime error. The reason for this exception is:
         The object "XVBFA" has a different object type in the dataset from
         that in the target program "ZMM_SERVICE_PO". (Object types: Field, flat
          structure,
         deep structure, flat table, deep table).
    Missing Handling of System Exception
        Program                                 ZMM_SERVICE_PO
    Trigger Location of Exception
        Program                                 ZMM_SERVICE_PO
        Include                                 ZMM_SERVICE_PO
        Row                                     43
        Module Name                             START-OF-SELECTION
    Source Code Extract
    Line  SourceCde
    REPORT  ZMM_SERVICE_PO.
    DATA: l_poheader      LIKE bapimepoheader.
    DATA: l_poheaderx     LIKE bapimepoheaderx.
    DATA: l_poitem        LIKE bapimepoitem     OCCURS 0 WITH HEADER LINE.
    DATA: l_poitemx       LIKE bapimepoitemx    OCCURS 0 WITH HEADER LINE.
    DATA: l_cond          LIKE BAPIMEPOCOND     OCCURS 0 WITH HEADER LINE.
    DATA: l_condx         LIKE BAPIMEPOCONDX    OCCURS 0 WITH HEADER LINE.
    DATA: l_poschedule    LIKE bapimeposchedule OCCURS 0 WITH HEADER LINE.
    DATA: l_poschedulex   LIKE bapimeposchedulx OCCURS 0 WITH HEADER LINE.
    DATA: l_purchaseorder LIKE bapimepoheader-po_number.
    DATA: l_return        TYPE BAPIRET2 OCCURS 0.
    DATA: l_error_found   TYPE c.
    DATA: l_show_messages TYPE c.
    DATA: l_eindt(10)     TYPE c.
    DATA: l_answer        TYPE c.
    DATA: l_VBAK          TYPE STANDARD TABLE OF VBAK WITH HEADER LINE.
    DATA: l_VBFA          TYPE STANDARD TABLE OF VBFA WITH HEADER LINE.
    DATA: xlips           TYPE STANDARD TABLE OF LIPS WITH HEADER LINE.
    *DATA: xvbfa           TYPE STANDARD TABLE OF vbfa WITH HEADER LINE.
    DATA xvbfa like vbfa.
    DATA: l_key(60) type c.
          concatenate 'SERVICEPO' sy-datum into l_key.
    >>>>> import xvbfa = xvbfa
                      from shared buffer indx(st) id l_key.
          delete from shared buffer indx(st) id l_key.
    Could you help.
    Regads,
    Shobhit

  • Language other than bash for calling external programs

    Hi,
    sorry for the unspecific title, I couldn't think of a better summary.
    The problem is this: I have written a script to encode a DVD to H264 and Vorbis. Since it basically just performs some (OK, by now: A lot of.) management and then calls a external programs, Bash was the obvious choice.
    However, the administrative stuff the script does (evaluating user input, calculations etc.) was already a nightmare to code in Bash (lack of arithmetic, lack of data types, proper functions, lack of c-like structs etc.), and I now want to make it even more flexible in what the user (me) can ask of it (it's also going to use a config file, which is another thing that gets ugly fast). Frankly, I can't stomach that.
    So the question is this: What language would be sensible for a program the most important function of which is calling other programs?
    Simply executing them from the main program isn't enough, unfortunately, because I want to make use of multicore system by for example simultaneously extracting streams and encoding them (right now that is done through named pipes), ideally I'd need a way to multithread not internal functions/routines but external programs (Through pipes or whatever).
    I'd prefer an interpreted language, but it's not a requirement.

    I second what peets said. Perl is definitely you're best option here, in my opinion anyways. It has the best (by which I mean easiest) system interface of any scripting langauge I've worked with, and if you want a simple configuration file reader, perl's regex'es are king. Perl also takes a lot of features from the shells, such as the file test operations. If the project get's really big and hairy though, it might be worth considering python as a cleaner, stricter alternative.
    Hope that helps!

  • Calling External Program

    Hi all,
    I’m currently doing a program that will trigger an external batch (.bat) program. I’m using WS_EXECUTE function module to trigger the external program. I need to know that whether ABAP will wait until the external bat program run completed then only will go back to the calling program and execute the rest of the ABAP code; or the WS_EXECUTE will just trigger the external program then continue the rest of the code in ABAP.
    Best regards,
    Patrick

    Hi Uma,
    FYI, I've run a thorough test, it will run synchronously though it calls an external program.
    I shall take note of the obsolete FM.
    Many thanks,
    Patrick

  • Calling external program on application server

    Hi, everyone. I'm trying to call an external program from ABAP by using SM69 and FM SXPG_COMMAND_EXECUTE
    MOVE 'zlong_bat' to ld_comline.         "Maintained using trans SM69
    * Execute external command, contained in 'ld_comline'
      CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
           EXPORTING
                commandname                   = ld_comline
    *           additional_parameters   = ld_param  "Params passed to script
    *           operatingsystem               = 'UNIX'
           IMPORTING
                status                        = ld_status
           TABLES
                exec_protocol                 = ld_output
           EXCEPTIONS
                no_permission                 = 1
                command_not_found             = 2
                parameters_too_long           = 3
                security_risk                 = 4
                wrong_check_call_interface    = 5
                program_start_error           = 6
                program_termination_error     = 7
                x_error                       = 8
                parameter_expected            = 9
                too_many_parameters           = 10
                illegal_command               = 11
                wrong_asynchronous_parameters = 12
                cant_enq_tbtco_entry          = 13
                jobcount_generation_error     = 14
                OTHERS                        = 15.
      IF sy-subrc NE 0.
      ENDIF.
    In the  sm69, I define zlong_bat with
        Operating system command: cmd
         Parameters for operating system command: /c remoteconn.bat
    It can run well if remoteconn.bat contain some simple command of dos like dir, md, mk... But when I call a program from remoteconn.bat, the abap program hang. I also cannot test in sm69 because it hang too.
    If I call direcly from sm 69 with
         Operating system command: cmd
         Parameters for operating system command: /c  psexec.exe
    localhost -u test -p 1234
    or
         Operating system command: C:\psexec.exe
         Parameters for operating system command: 
    localhost -u test -p 1234
    The SM69 also hang.
    Are there any method to call a program from sap without hanging
    of course the program is in its position on application server.
    Thank you in advance.
    Regards,
    Long
    Edited by: dragonking88 on Aug 25, 2010 12:54 PM

    Hi Long Le Hoang,
    I am running a shell script fromSM69 which call psexec.
    shell script runs fine but SM69 execution goes on hold.
    Can you please help me how to terminate SM69 execution.
    Alpa

  • Calling external programs using labview

    I have a LV program running to collect and display data, but also need to call an external program while doing this. I have a menu set up where one button launches my system control .vi, one launches my data display .vi, but there is another feature that is handled by a program a co-worker has written. Is there a way that whenever a button is pressed, LV can launch an external .exe file? Basically, I just need LV to call the executeable... the program that is called will be terminated by the user.
    Jim

    Try function palette -> Communication -> System Exec.vi
    George Zou
    http://gtoolbox.yeah.net
    George Zou
    http://webspace.webring.com/people/og/gtoolbox

  • AIR-Calling External Program

    hi, i am making an AIR application and i want to execute an external program through this, or suppose that i want to call a java program on client machine, i don't want to have any server to do this, is there any way to do that ?, plz let me know
    With Regards
    Amar Deep Singh

    I think your only option might Merapi, and that might only be for linking AIR and Java apps.
    http://merapiproject.net/
    If this post answers your question or helps, please mark it as such.
    Greg Lafrance
    www.ChikaraDev.com
    Flex Development, Training, and Support Services

  • Call external program without intermediate step

    When I call an external program (Nik Color Efex) a window opens asking me wether I want to continue with the image having all Lr stpes applied etc. How can I circumvent this "annoying" step and directly call the external program without interruption?

    Thanks, I understand that before transferring the file you need to do these preparations, but then the window shows up asking me wether I want to transfer the copy or the original...  I am looking for a mechanism to supress that screen.

  • FMS 4 FCUnpublish call external program

    Is it possible with server-side scripting for FMS to call an external program once a stream has been unpublished? Any links would be appreciated. Thanks.

    I've used the File Class from http://help.adobe.com/en_US/flashmediaserver/ssaslr/flashmediaserver_4.5_sslr.pdf to create a file each time an unPublish event is thrown. Then use an external program to monitor a directory where these log files get stored.
    Where there is a will there is always a way

  • Calling external program from PL/SQL

    Does anyone know whether it's possible to call an external program living outside of Oracle from PL/SQl eg. a from a stored procedure?
    Specifically i want to call back into my java appserver (ejb server) when a trigger/stored proc. is executed.
    The call does not have to be synchronous, some sort of queue will do - eg JMS??
    Any help greatly appreciated.
    null

    Hi
    Which version of oracle you are using.
    If it 8i, you can use external procedures/libraries. REfer to ORacle PLSQL documentation.
    If you are using Oracle 7+ you can use dbms pipes to post your command string and a cron job to read the pipe and execute the string.
    An alternate ugly way is to write to a file and some process reading the file at a regular interval.
    HTH
    Arvind Balaraman

  • Calling external programs from within a Tomcat application

    I've got a fairly complex existing Tomcat application (which is packaged and built as a .war file) which I'm trying to edit so that it calls a Perl script part way through the processing, which will generate an XML file used later on. I think I've worked out how to call external scripts from within Java, but at the moment when I try and access the application via Tomcat the application either hangs or bails out (I don't know which, as the log files unhelpfully don't give any error messages).
    The code which is causing the problem looks like this:
    System.err.println("Calling runtime...");
    Runtime runtime = Runtime.getRuntime();
    System.err.println("Executing process...");
    Process process = runtime.exec("/path/to/ysearch.pl 'News' '\"search query\"' 'file");
    System.err.println("Waiting for process...");
    int exitVal = process.waitFor();
    System.out.println("Exited with error code: " + exitVal);The code gets as far as "Executing process..", beyond that there is nothing in the log file so I presume the runtime.exec() call is where the problem is. I'm not interested in reading the output from the script (there shouldn't be any), so that's not an issue, and the permissions on it allow anyone to read or execute ysearch.pl so I don't think there's a problem in that area.
    Does anyone have any suggestions which I could try to get this to work? I've only been using Tomcat for a week (I'm picking up on someone else's code) so I might have made a beginner's mistake. I'm using Tomcat 5 on Fedora Core 7, and Java 1.5.0_01 (I can't easily change any of those).

    I'm not sure, but I thing that overhead caused by calling du cannot be big enough to matter even on older machines.
    But, when calling du from Perl script you are also invoking shell, and this can be a little bit more 'heavy'.

  • Calling external programs from Java?

    Hi All,
    Is there a way of calling external applications from Java without using Runtime.exec(). That method seems quite messy when you are dealing with streaming data from an input file to an output file. Basically what I'm asking is there a way to run a command the same way you would type it in a command shell?
    Thanks

    LeWalrus wrote:
    Ok, I've an external application that I want to be called inside a Java GUI. It has several input arguements, which the format looks something like:
    programname inputfile > outputfile
    Simple enough.
    >
    Works fine from a shell command line. From what I understand, this won't work using Runtime.exec() because that method will just start the application. Works fine from Runtime.exec(). Since you are'>' to write stdout to a file you need to us a shell to execute the command.
    String[] command = {"sh", "-c","programname inputfile > outputfile"};
    Process process = runtime.exec(command);
    You need to read, digest and implement the recommendations given in http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html .
    File input and output from the application has to be taken care of programatically (java.io stuff). Fine if you've only one input and output. But if you have several input files and hundreds of output files, where does this leave you. It would be much easier if you could pass a string command to the shell directly as if you typed it in the command line yoursel!

  • 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.

  • Anonomly seen in calling external program???

    Hi folks,
    Below I am trying to execute another java application I made, when calling it from the default constructor of another separate java program I made.
    In the serverload.bat the lines:
    REM notepad.exe
    d:
    cd java
    java MultiThreadServerRead
    In the constrctor I have the below:
    try
                        Runtime.getRuntime().exec("cmd.exe /c d:\\java\\serverload.bat");
                        Process p= null;
                        Runtime r= Runtime.getRuntime();
                        p=r.exec("d:\\java\\serverload.bat");
                   catch (Exception e)
                        System.out.println("Myerror message "+e.getMessage());
    When the application starts, it just flies right past the above and does not load the external java application?? If I put an exe there it works okay?? Whats going wrong?

    I dont know why that wont work, but you could just make sure the class for the serverload is in your classpath and just create a new instance of it:
    new serverload();
    or
    new path.to.your.class.serverload(Constructor,Params);
    You might have to do a little modification to your serverload class to make your constructors do everything and take you code out of main to only call the constructor:
    public static void main(String[] args) {
    serverload app = new serverload();
    app.launchApp();
    public SQLFileExec() {
    launchApp();
    private void launchApp() {
    .. your main code goes here.
    You could also use threads to disconnect the application form you parrent.
    Does this help?
    Tim Strunk

Maybe you are looking for