I need to call a batch file from java and pass arguments to that Batch file

Hi,
I need to call a batch file from java and pass arguments to that Batch file.
For example say: The batch file(test.bat) contains this command: mkdir
I need to pass the name of the directory to the batch file as an argument from My Java program.
Runtime.getRuntime().exec("cmd /c start test.bat");
How to pass argument to the .bat file from Java now ?
regards,
Krish
Edited by: Krish4Java on Oct 17, 2007 2:47 PM

Hi Turing,
I am able to pass the argument directly but unable to pass as a String.
For example:
Runtime.getRuntime().exec("cmd /c start test.bat sample ");
When I pass it as a value sample, I am able to receive this value sample in the batch file. Do you know how to pass a String ?
String s1="sample";
Runtime.getRuntime().exec("cmd /c start test.bat s1 ");
s1 gets passed here instead of value sample to the batch file.
Pls let me know if you have a solution.
Thanks,
Krish

Similar Messages

  • I can't open pages files from USB and iCloud due to : "The necessary file index.xml is missing".

    I can't open pages files from USB and iCloud due to : "The necessary file index.xml is missing". Original file is written on iMac (2014) and saved to an USB stick and then transferred till macBook Pro (2009, Yosemite) for editing. Then I shared the files by iCloud but I am not able to open them on iMac again. Niether can I use the USB stick to transfer the edited files back. I'm running Pages '09 4,1 (923) on the macBook and Pges 5.5.2 (2120) on the iMac.
    Håkan

    Pages 5.5.2 is extremely incompatible with even other Macs let alone the vast majority of PC and MsWord users out there, so not a good idea to leap into the fire with both eyes shut.
    After having done that to the first Pages 5 files, Apple has repeatedly done it to even the most minor point updates. Apple can't even anticipate its own erratic changes let alone what everyone else needs doing.
    Peter

  • Need to call webservice WSDL directly from Java code

    Hi All,
    I hope u all are doing great.
    I am new to web services and i have a requirement where i need to call the webservice directly from the java code, we dont need any middle layer(via proxy n all).
    Can you all please help me on this, we are using Jdeveloper 11g and we do have WSDLs
    we shld be able to use the wsdl in code and pass the request and get the request
    Any help will be appreciated
    Thanks

    @Puthanampatti     
    Thanks, but i already went through this link and seems this link also says we need to access webserivice through stub,dii etc.
    I want straught java code to access webservice without any tier in between
    Thanks

  • Calling JSP file from applet and passing a parameter in POST form

    Hi,
    Can anybody help me. I want to call a JSP page from within a applet and to this JSP page i want to pass the query which the applet has created in POST method.
    I want to refresh the applet page with the new JSP page by passing the query object so the jsp page with take this query, and display the resultset
    Thanks in advance
    JK

    Review
    URL.openConnection()
    and HttpURLConnection

  • Need to call a recursive SP from Java code

    I have a table with parent child relationships as:
    CREATE TABLE parent_child
    parentid NUMBER,
    childid NUMBER
    Each child can have more than one parents. Now for a given child i need to find all the parents. My solution is a stored procedure as follows:
    CREATE OR REPLACE PROCEDURE Sp_Getparents(child_id IN NUMBER)
    IS
         CURSOR parents IS
    SELECT parentid FROM PARENT_CHILD WHERE PARENT_CHILD.childid = child_id;
    BEGIN
    FOR parents_cur IN parents LOOP
    DBMS_OUTPUT.PUT_LINE(parents_cur.parentid);
         Sp_Getparents(parents_cur.parentid);
    END LOOP;
    END Sp_Getparents;
    This prints the non-distinct values fo all parents to a value.
    Now my problem starts when i wish to access the result of this SP from my java code.
    For that i have no idea if a DBMS_OUTPUT will give me a resultset or not. If not, then what is the way to do so. I tried creating a REF CURSOR for the same, but was not able to test the result out on sqlplus.
    Can anyone help me on this?
    Thanks in advance
    Pankaj

    You need to return a refcursor like this (9i and up)
    CREATE OR REPLACE
    FUNCTION sp_getparents(child_id IN NUMBER) RETURN SYS_REFCURSOR
    IS
      c SYS_REFCURSOR;
    BEGIN
      OPEN c FOR
        SELECT parentid
        FROM parent_child
        WHERE parent_child.childid = child_id;
      RETURN c;
    END sp_get_parents;
    show errorsif you want to test this in SQL*Plus:
    var c refcursor;
    exec :c := sp_getparents(3);
    print c;hope this helps
    chet

  • I am trying to download itunes but it says that a file is corrupt and i cant find that speific file, does anyone kno wat is wrong???

    It says that a speific file had an error while downloading, i tried to download quicktime to think it would fix it, but it gave me the same error
    'Microsoft.VC80.CRT.type="win32".version="8.0.50727.6195".publicKeyToken="1fc8b3 b9a1e18e3b".processorArchitecture="x85'". then when i push ok, it'll roll pack the download and do the same thing over and over again, plz help!!!

    i have the same problem, i have a windows 7 and the little screen comes up saying statues: processing additional packages  help us

  • HT2470 how would i go about taking multiple files from documents and make them part of 1 master file

    how would i go about taking multiple files from documents and make them into 1 master file? I want to put all documents associated with this project together for easier access.

    From the finder window, click File, click new folder, you can drag all documents into that Folder making it the master folder. You can ajso drag folders into the Master folder, and have them as sub-folders if you wish to  do that. Either way they will all be in one master folder.

  • Running  .nsi file from java

    hi,
    Ho to run .nsi file from java.
    thanks in advance.

    User845466 wrote:
    Ho to run .nsi file from java.Find the program hanling that kind of documents an launch this via Runtime.exec() giving it your *.nsi file as a parameter.
    bye
    TPD

  • Executing batch file from Java stored procedure hang

    Dears,
    I'm using the following code to execute batch file from Java Stored procedure, which is working fine from Java IDE JDeveloper 10.1.3.4.
    public static String runFile(String drive)
    String result = "";
    String content = "echo off\n" + "vol " + drive + ": | find /i \"Serial Number is\"";
    try {
    File directory = new File(drive + ":");
    File file = File.createTempFile("bb1", ".bat", directory);
    file.deleteOnExit();
    FileWriter fw = new java.io.FileWriter(file);
    fw.write(content);
    fw.close();
    // The next line is the command causing the problem
    Process p = Runtime.getRuntime().exec("cmd.exe /c " + file.getPath());
    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while ((line = input.readLine()) != null)
    result += line;
    input.close();
    file.delete();
    result = result.substring( result.lastIndexOf( ' ' )).trim();
    } catch (Exception e) {
    e.printStackTrace();
    result = e.getClass().getName() + " : " + e.getMessage();
    return result;
    The above code is used in getting the volume of a drive on windows, something like "80EC-C230"
    I gave the SYSTEM schema the required privilege to execute the code.
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    GRANT JAVAUSERPRIV TO SYSTEM;
    I have used the following to load the class in Oracle 9ir2 DB:
    loadjava -u [system/******@orcl|mailto:system/******@orcl] -v -resolve C:\Server\src\net\dev\Util.java
    CREATE FUNCTION A1(drive IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'net.dev.Util.a1(java.lang.String) return java.lang.String';
    variable serial1 varchar2(1000);
    call A1( 'C' ) into :serial1;
    The problem that it hangs when I execute the call to the function (I have indicated the line causing the problem in a comment in the code).
    I have seen similar problems on other forums, but no solution posted
    [http://oracle.ittoolbox.com/groups/technical-functional/oracle-jdeveloper-l/run-an-exe-file-using-oracle-database-trigger-1567662]
    I have posted this in JDeveloper forum ([t-853821]) but suggested to post for forum in DB.
    Can anyne help?

    Dear Peter,
    You are totally right, I got this as mistake copy paste. I'm just having a Java utility for running external files outside Oracle DB, this is the method runFile()
    I'm passing it the content of script and names of file to be created on the fly and executed then deleted, sorry for the mistake in creating caller function.
    The main point, how I claim that the line in code where creating external process is the problem. I have tried the code with commenting this line and it was working ok, I made this to make sure of the permission required that I need to give to the schema passing security permission problems.
    The function script is running perfect if I'm executing vbs script outside Oracle using something like "cscript //NoLogo aaa1.vbs", but when I use the command line the call just never returns to me "cmd.exe /c bb1.bat".
    where content of bb1.bat as follows:
    echo off
    vol C: | find /i "Serial Number is"
    The above batch file just get the serial number of hard drive assigned when windows formatted HD.
    Same code runs outside Oracle just fine, but inside Oracle doesn't return if I exectued the following:
    variable serial1 varchar2(1000);
    call A1( 'C' ) into :serial1;
    Never returns
    Thanks for tracing teh issue to that details ;) hope you coul help.

  • How to call a .bat file from java code?

    How to call a .bat file from java code? and how can i pass parameters to that .bat file?
    Thanks in advance

    thanks for ur reply
    but still i am getting the same error.
    I am trying to run a .bat file of together tool, my code looks like below
    import java.lang.Runtime;
    import java.lang.Process;
    import java.io.File;
    class SysCall{
         public static void main(String args[]){
              String cmd="D://Borland//Together6.2//bin//Together.bat -script:com.togethersoft.modules.qa.QA -metrics out:D://MySamples//Metrics// -fmt:html D://Borland//Together6.2//samples//java//CashSales//CashSales.tpr";
              //String path="D://Borland//Together6.2//bin//Together.bat ";
              Runtime r= Runtime.getRuntime(); //Declare the system call
              try{
                   System.out.println("Before batch is called");
                   Process p=r.exec(cmd);
                   System.out.println(" Exit value =" + p.exitValue());
                   System.out.println("After batch is called");
              /*can produce errors which must be caught*/
              catch(Exception e) {
                   e.printStackTrace();
                   System.out.println (e.toString());
    I am getting the below exception
    Before batch is called
    java.lang.IllegalThreadStateException: process has not exited
    at java.lang.Win32Process.exitValue(Native Method)
    at SysCall.main(SysCall.java:17)
    java.lang.IllegalThreadStateException: process has not exited

  • Call .bat file from java code

    I need to call an application that uses a .bat file to execute from a java program. Is that possible?
    This is the .bat file:
    importcli.exe ciaf2735 C:\Importcli\files\SAI2735*.txt  
    importcli.exe ciaf2735 C:\Importcli\files\CI2735*.txt  
    importcli.exe ciaf2735 C:\Importcli\files\SC2735*.txt  
    importcli.exe db1800 C:\Importcli\files\*.mdb

    magaupe wrote:
    I need to call an application that uses a .bat file to execute from a java program. Is that possible?
    This is the .bat file:
    importcli.exe ciaf2735 C:\Importcli\files\SAI2735*.txt  
    importcli.exe ciaf2735 C:\Importcli\files\CI2735*.txt  
    importcli.exe ciaf2735 C:\Importcli\files\SC2735*.txt  
    importcli.exe db1800 C:\Importcli\files\*.mdb
    Hmmm, I wonder what would happen if there were a web search engine and you could research like this:
    [http://www.google.com/search?hl=en&q=call+.bat+file+from+java]

  • 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

  • Need to create a function to receive binary files from Java WebDynpro

    Hey,
    I need to recieve files from java Webdynpro and save them as a file on the backend
    system. After that, the file will be loaded to the documentum.
    In a function module, I only can get the files as a String. Therefore (I think), I need the
    binary file as base64 encoded. Otherwise I can´t get it as a string.
    Now I need to decode it in the backend, but how? I know, there are HTTP-classes
    in newer system, but not in the 4.6C System, I have here.
    Any idea, how I can recieve the files in the function module and transfer it as binary
    file to the backend system?
    If I load a file from the gui with gui_upload, I get the binary file as an internal table
    and can transfer it to the backend filesystem now. Maybe I can get the binary file
    in this way in the function?
    Thank You for Your help!
    Arne

    http://jakarta.apache.org/commons/net/

  • How can i call forpro prg file from java

    Hai friends,
    I have a doubt,clear it.
    how can i call forpro prg file from java file
    by,
    N.Vijay

    Thanks to your reply,
    I have some print statements in my foxpro program file.
    Then i like to invoke that foxpro file from my java file
    This want i want..,
    by,
    N.Vijay

  • How to Call .XDO file From Java Program

    Hi,
    I have developed a report in using BI Publisher version 10.1.3.
    I created the report and it only created XDO files. If I want to call XDO file from Java program how I can do that.
    What are the APIs available to do that.
    Thanks
    -Ashutosh

    Hi,
    the JavaAPI didn't work with the xdo-Files. But you can create a proxy stub for the Web Service API of BI Publisher which uses the xdo's in the repository.
    regards
    Rainer

Maybe you are looking for

  • Xml publisher graph is not displaying

    Hi All, I have created xml report which is having graph .It display through oracle apps(conc pgrm ) properly in test instance but after moving to production graph is not displaying .for that i have checked Xserver setup also everything is working fin

  • TS4062 I cannot find my IPOD touch listed on ITunes (there is no "Device" menu option - any advice?

    I cannot find my IPOD touch listed on ITunes (there is no "Device" menu option in iTunes- any advice?). Using IPOD touch (32gb) and connecting with a laptop using Windows Vista. Downloaded the latest ITunes and it wiped all my music. I was able to re

  • Can OS X 10.9 Authenticate An Active Directory User From A Different Trusted Forest

    I am able to authenticate with an AD account from a different trusted domain in the same forest as the domain the client is bound to on OS X 10.9. An AD account from a trusted domain in a separate forest cannot authenticate on the same client. The sa

  • Multiple front panels

    My problem VI consists of a Main UI where the operator can initiate tests. The tests are sub-vi's and I only need one of those active at a time.  However, there are some general routines that I have together in another sub-vi called from the Main UI.

  • Lost pdf-Emails

    How can I  find  and  open/print  encoded pdf-E-mails which  somehow  have  been lost