How to execute a DOS PROGRAM as batch file  in java

How to execute a DOS PROGRAM as batch file in java
pls help me

www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Similar Messages

  • How to execute a Window program from Unix box using Java

    I am trying to execut a program running on a Window box from Shell Script on a Unix box. Does anybody knows how to do that using Java. Thanks. Any feedback appreciated.
    kevin

    You need to use
    String fileNane = "setup.exe";
    Runtime.getRuntime().exec(fileName);that is if you are writing code
    if you are just calling if from a terminal just write
    java then the file name ( well I think that is right :)
    I do know that the code above work as I have it working on a windoze box
    Craig
    Hope this is right if not please let me know

  • DOS command for batch file

    Hi All,
    anybody knows how to call a batch file from java
    is there any DOS command aor dll file like url.dll by wich i can call my batch file from a java file
    or may be some body can tell me how to use FileUploadProtocal to call a batch file from java
    Please help me
    ASAP
    Thanks in advance

    Actuly I got these lines from a frnd
    String loadPath = "rundll10 url.dll,FileProtocolHandler D:\\a.bat";
    Process process = Runtime.getRuntime().exec(loadPath);
    but my original code was
    try{
         boolean imported = true;
         String _cmd = "cmd /c ";
         cmd =cmd+"sqlldr ";
         cmd = cmd + " userid=" + userId + "/" + passwd + "@"+ tnsEntry;
         cmd = cmd + " control=" + controlFilePath;
         cmd = cmd + " log=sql.log skip=1";
         System.out.println(_cmd);
         String envArr[] = new String[2];
         envArr[0] = "ORACLE_HOME=" + System.getProperty("ORACLE_HOME");
         envArr[1] = "PATH=" + System.getProperty("PATH");
              try{
                   Runtime r = Runtime.getRuntime();
         Process process = r.exec(_cmd);
              catch(RuntimeException re )
                   System.out.println("Failed to runtime run the process.123.."+re);
    it was not working even i m not getting any error or excep. so I tried that two lines above.
    but still frustating results

  • How to run a ABAP Program in Batch JOB

    How to run a ABAP Program in Batch JOB ?

    Hello Manish,
    Using transaction SM36 you can define the batch job along with the start conditions for that job.
    1. Transaction SM36.
    2. Give the Z name of the job in the 'Job Name' input field.
    3. Click on 'Steps' button from the application toolbar.
    4. On the 'Create Step 1' dialog box, give the name of the ABAP program in the 'ABAP Program' section' along with the variant.
    5. Click on 'Check Input' button from the dialog box.
    6. Click on 'Save' button from the dialog box once the check is successful.
    7. One list will be shown. Click on Back button from the standard toolbar.
    8. Click on 'Start Conditions' button from the application toolbar. Specify the start condition e.g. immediate. Click on save.
    9. The job staus is now scheduled.
    10.Click on Save button from the standard toolbar of SM36. The job status will be released.
    Using SM37 you can monitor the status of the job.
    This will sort out your problem.
    PS If the answer solves your query, plz reward points.
    Regards

  • How to execute a Print program, if it is an INclude program?

    Hello,
    Very Good evening!
    How to execute a Print program of a samrt form..if it is an INclude program...?
    And, There is a T-code to debugg Smart form...It should be something SSFTRACE.....Please correct me...If you know the correct T code.
    Regards,
    Kittu

    Everything is done ..It is configured in NAce with the appropriate Output type....
    I had types ME23n, Me22N and cheked with the value....It is displaying the PO values...But, in print privew it is not displaying it ...It just display's the big white sheet.
    For this reason I need to check with the parameter values of Function module which is used in INclude progeram....I set Break points at the Function Module....Now, please tell me how can I chk the values of teh parameters. As, it is an Include program it will not let me switch on the debugger.... So, is there any other way that i can debugg them by setting break points?
    PLease help....
    Thank you,
    Kittu

  • Can't execute a DOS program from a Java one

    Hi everyone !
    I'm a student, working as an apprentice in a company, and I have to make a program to execute faster some daily routine.
    Here's my problem : I'm trying to execute a DOS program (mkisofs.exe) whick takes numerous arguments and enables me to create an ISO file.
    But, for now, I can't manage to make it work. I've used both Process and ProcessBuilder, but in vain (I'm a student, and not really a JavaProgrammingStar).
    If I would manually execute the command, I'll have to type under DOS the following command :
    "C:\Documents and Settings\myName\Desktop\Current\Local\mkisofs.exe"   -r -J -l -L -b "isolinux/isolinux.bin" -c "isolinux/isolinux.cat" -no-emul-boot -boot-load-size 4 -boot-info -table -graft-points -o D:\ISO\toto.iso "C:\Documents and Settings\myName\Desktop\Current\Local\Clonezilla"or (without spaces)
    C:\docume~1\myName\Desktop\Current\Local\mkisofs.exe   -r -J -l -L -b "isolinux/isolinux.bin" -c "isolinux/isolinux.cat" -no-emul-boot -boot-load-size 4 -boot-info -table -graft-points -o D:\ISO\toto.iso C:\docume~1\myName\Desktop\Current\Local\ClonezillaTill now, I've only managed to execute windowed program such as MsPaint.exe or DOS program from System32 directory such as taskkill.exe, but I couldn't execute, for example, tasklist.exe, or at least, I couldn't see the result of this command.
    Can anyone help me ?
    If some code is needed, jsut tell me.
    Thanks by advance !
    Hubert

    Ok guys, I'm French, so excuse me if I didn't use the correct terminology, but I'm quite sure you understood that I was talking about MS-DOS command prompt in Windows XP.
    Then, of course I've STFW, but none on my tries was successful. So a little help would be appreciated.
    I've first tried this :
    ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/K", "mspaint.exe");
                      pb.redirectErrorStream(true);
                      try {
                          Process p = pb.start();
                          BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
                          try {
                              String rep = in.readLine();
                              System.out.println(rep);
                          } finally {
                              in.close();
                      } catch (IOException e) {
                          e.printStackTrace();//repTF.setText("erreur");
                      }It worked.
    But this :
    String CMD = "C:\\docume~1\\myName\\Bureau\\Current\\Local\\mkisofs.exe";
    String arg1 = "-r -J -l -L -b \"isolinux/isolinux.bin\" -c \"isolinux/isolinux.cat\" -no-emul-boot -boot-load-size 4";
    String arg2 = "-boot-info -table -graft-points -o D:\\ISO\\toto.iso C:\\docume~1\\myName\\Bureau\\Current\\Local\\Clonezilla";
    ProcessBuilder pb = new ProcessBuilder(CMD, arg1, arg2);
                      pb.redirectErrorStream(true);
                      try {
                          Process p = pb.start();
                          BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
                          try {
                              String rep = in.readLine();
                              System.out.println(rep);
                          } finally {
                              in.close();
                      } catch (IOException e) {
                          e.printStackTrace();//repTF.setText("erreur");
                      }does'nt.
    What's wrong ? I should use a String table for args ?

  • 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 create a Batch file for java application and whats the use of this ?

    HI,
    How to create a Batch file for java application ?
    And whats the use of creating batch file ?
    Thanks in advance

    First of all, you're OT.
    Second, you can find this everywhere in the net.
    If you got a manifest declaring main class (an classpath if needed), just create a file named whatever.bat, within same directory of jar file, containing:
    javaw -jar ./WhateverTheNameOfYourJarIs.jar %*By the way, assuming a Windows OS, you can just double click the jar file (no batch is needed).
    Otherwise use:
    javaw -cp listOfJarsAndDirectoriesSeparedBySemiColon country/company/application/package/className %*Where 'country/company/application/package/' just stands for a package path using '/' as separator instead of '.'
    Don't specify the .class extension.
    Javaw only works on Windows (you asked for batch, I assumed .BAT, no .sh), in Linux please use java.exe (path may be needed, Windows doesn't need it 'cause java's executables are copied to system32 folder in order to be always available, see PATH environment variable if you don't know what I'm talking about) and use ':' as classpath (cp) separator.
    The '%***' tail is there in order to pass all parameters, it only works on Windows, refer to your shell docs for other OSs (something like $* may work).
    This way you have a command you can call to launch your code (instead of opening NetBeans just to see your app working). You could schedule tasks on it or just call it in any command prompt (hope you know what it is 'cause there have been people in this very same forum with no clue about it, if not just hold the 'Windows button' and press 'R', then type 'cmd' and run it).
    Finally add dukes and give 'hem away.
    Bye.

  • Adobe AIR - java is not recognized as an internal or external command operable program or batch file

    Hi,
    I've done everything as in the HelloWorld tutorial but when i run this cmd: adt
    it gives me the following error java is not recognized as an internal or external command operable program or batch file
    I've installed the AIR runtime v2
    Downloaded the SDK v2 and placed in D:\Www\air
    Modified the path variable with D:\Www\air\bin
    And then i open a new cmd console and simply write adt and gives me that error.
    I've updated to the latest version of Java, but it did solve it.
    But what's strage it's that the adl command work, but i'm not being able to pack my application.
    I'm running Windows 7 on x64 platform.
    Sincerely,
    Alex

    I think the 32bit version will work, but it sounds like you'll need to add the Java bin folder to your system path.  This is usually done by the Java installer, so I'm not sure what failed, did you run the installer located at www.java.com?  Either way, this document might be able to help you out:
    How do I set or change the PATH system variable
    Add the Java "bin" folder to your path, you might also need to add the CLASSPATH.
    Please let me know how it goes!

  • How to create a Batch file for java application  ?

    HI,
    How to create a Batch file for java application ?
    And whats the use of creating batch file ?
    Thanks in advance

    [http://static.springsource.org/spring-batch/]
    Assuming you want to develop a batch application rather than actually just create a .bat file ..

  • (SCM-APO ) - LiveCache error - tp error : operable program or batch file

    Dear Gurus,
    On one our APO systems, I cannot administer liveCache, using database connection LCA, LDA, or LEA. Using LCA as an example, with
    tcode LC10> liveCache Monitoring, I get this error:
    Name and Server :    QDP - ntsapsc001
    DBMRFC Function  : DBM_CONNECT
    Error : DBM Error
    Return Code : -11
    Error Message : tp error: operable program or batch file
    Using tcode /sapapo/om13, I get these results:
    liveCache connection to LCA      (GREEN)
    liveCache Stat. from LCA     ???    (RED)
    liveCache Initialization          001   (RED)
    Using tcode SE38> program RSLVCINIT > database connection LCA, I get this error:
    Error in DBMSERVER or DBMCLI
    What is wrong ?
    Thanks and regards,
    cjperk90

    In the syslog (tcode sm21), and on the NT server's syslog,
    I also get these errors:
    Database error -10709 at CON
    > Connection failed (RTE:database not running)
    Please advise.
    Thanks,
    cjperk90

  • 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

  • Running a batch file in Java. Urgent!!

    I want to run a batch file present at a particular location in Java.Although I am running two codes suggested by many people, i am still not able to run the batch file. My codes run as below :-
    CODE 1
    Process P;
    Runtime rt = Runtime.getRuntime();
    P = rt.exec("C:\\test.bat");
    CODE 2
    Process P;
    Runtime rt = Runtime.getRuntime();
    P = rt.exec("C:\\WINNT\\System32\\cmd.exe C:\\test.bat");
    I have tried both these codes but without success. But I have observed that in the Task Manager, whenever i run the above codes in a servlet, a "CMD.EXE" is being created in the "Processes" Bar each time but the batch file neither opens up nor it runs.
    Please suggest me some method to run this batch file in Java.
    Or if u can suggest the reason behind the above observation and any corrections i can make to run the batch file. Thanks in advance.
    Ankit

    i want to get more than one command prompt while running the program
    am giving the problem
    import java.io.*;
    class CmdDemo
         CmdDemo(String ls) {
              try
              Process p;
              Runtime rt=Runtime.getRuntime();
              p=rt.exec(ls);
              catch(IOException ioe)
                   System.out.println(ioe);
         void showcmd(){
    new CmdDemo("cmd");
         public static void main(String args[])
              new CmdDemo("cmd");
              new CmdDemo("C:/WINDOWS/System32/cmd.exe");
              new CmdDemo("cmd");
              new CmdDemo("regedit");
              new CmdDemo("regedit");
              new CmdDemo("notepad");
              new CmdDemo("notepad");
              //CmdDemo cd=new CmdDemo("cmd");
              //cd.showcmd();
    here am getting two notepads ,two registry editors
    but only one command window
    i would be very greateful if u could help me
    plz reply to my id [email protected] too

  • Running batch files thraugh java by passing parameters

    Hi
    I want to run a batch file by passing some parameters.
    Eg: copy.bat "D:\live\hoe.txt" "D:\test"
    while doing this from command prompt its working and i have written some java code for running this batch file.
    String live="D:\\live\\how.txt";
    String test="D:\\test";
    String bat="D:\\copy.bat";
    String[] command = new String[3];
    command[0] = bat;
    command[1] = live;
    command[2] = test;
    try {
    Runtime.getRuntime().exec(command);
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    but this time its not copying the file;
    Please help.

    Just another cross poster.
    [http://www.java-forums.org/new-java/15005-running-batch-files-thraugh-java-passing-parameters.html]
    db

  • How can I using functions implicit in dll file in java code ?

    How can I using functions implicit in dll file in java code ?
    I'm developing a program that interfacing with fingerprint hardware.
    I have the finger print already, and I have to the SDK that have all functions for managing this fingerprint.
    These SDK functions are represented in dll files.
    I want to know how can I use these functions in java code .
    I looked on this link of sun forums :
    http://forum.java.sun.com/thread.jspa?threadID=305171&messageID=1215613
    but I don't Understand the meaning of native code.
    Thanks for help.

    please please please please please please please please help me:
    After reading a lot of articles, tutorials, and overviews about JNI (Java Native Interface)
    I found that these steps
    1.     Develop the Java code
    2.     Compile the Java code to a class file
    3.     Generate the header file
    4.     Implement the native method
    5.     Create the shared library or DLL
    6.     Run the Java program
    Is the common steps in JNI development
    The most powerful link was
    http://java.sun.com/docs/books/jni/html/start.html
    and
    http://www.netbeans.org/kb/55/beginning-jni-part2.html
    and the pdf oh this link
    http://www.ibm.com/developerworks/edu/j-dw-javajni-i.html requiring IBM registration to download it.
    But I have already the DLL, and want to the stright forward way to use its functions by java code only.
    I don not to write any C++ code .
    Is this possible???????????????????????????????
    The name of these dll is �zkemsdk.dll�
    It developed by ZKSOFTWARE company for managing a finger print �NP1500A�of
    http://www.napcogulfsecurity.com/finger_print.asp
    thanks for help

Maybe you are looking for

  • Final Cut Pro X .mts, h.264, ProRes, Clipwrap 2...

    Hi guys, Newbie here! Tried serching but cant really nail down what im looking for. I'm trying to figure out editing (Panasonic Sd700) AVCHD 1080 60p, .mts files with Final Cut Pro X. I am aware that the files need converting etc etc, but I want to k

  • Generic Connection Framework Optional Package for J2SE

    i have learnt that the Generic Connection Framework Optional Package can be used to make J2SE able to use J2ME classes. However, how can i implement the package so that i can do so. Thank you for your advice.

  • Some doubt about Bdb XML Normal Recovery

    Hi, everyone I have read the document Getting Started with Transaction Processing for Java shipped with Bdb XML 2.4.13. In the book, there is something about Normal Recovery: Normal recovery is run only against those log files created since the time

  • Need guidance for ePubs for iBooks

    I'm a professional formatter and have converted files to ePubs for several years. Now some of my clients want to upload directly to iBooks with an Author account. Since I'm a PC person I don't work with MACs although I myself have an Apple account (I

  • FSCM-DM Auto Writeoff program

    Hi, When i execute UDM_AUTOWRITEOFF program system is able to execute and able to writeoff the dispute cases but it is unable to close the Dispute case. When i go in to the dispute case i am still able to make the changes. I am getting a update termi