Run a MS DOS batch file from the client

Hi,
I created a java source to run a bat file, the folder is loacted in the Database server.
(Not in application server)
create or replace and compile java source named execcommand as
import java.io.*;
import java.util.*;
public class ExecCommand{
public static void run(String cmdstr) throws IOException, InterruptedException
try {
int rtn;
cmdstr = "cmd /c " + cmdstr;
Process prcs = Runtime.getRuntime().exec(cmdstr);
while (prcs.getInputStream().read() != -1 ) {}
catch (IOException e) {
e.printStackTrace();
I called the java source from the procedure
create or replace procedure run_batfile is
begin
execcommand(cmdtext => 'e:\services\genPDF.bat');
dbms_output.put_line('file created successfully');
exception
when others then
dbms_output.put_line(sqlcode || sqlerrm);
end run_batfile;
But the bat is not executing (The bat file is to generate a PDF file ). Bu when i executing this from my PC (Client PC) directly on the RUN , its generating the PDF file in the server.
What could be the problem, What should be the path in the procedure,
Shall i create any virtual directory ?
Thanks in advance,
Rizly

Hi Justin ,
Sorry for the late replay.
I am running Oracle on Windows.
The MS DOS Batch file is to convert XML file to PDF format. It is a Java Application.
also it is a batch process, thats why i created a batch file for that. I am using FOP to convert XML to PDF.
FOP is in the e:\services folder of the Database Server machiene. XML file is also in the same forlder and I need to generate the PDF file also in the same machiene.
<<- You have a client machine. What do you mean by "executing this from my PC (Client PC) directly on the RUN , its generating the PDF file in the server.">>
I have mapped the e:\services folder in my client machience, so i am accessible to the genPDF.bat file that is in the 'e:\services' folder of the DB Server. When i run the bat file from my PC as Start > Run e:\services\genPDF.bat . The PDF file has generated in the DB Server machien.
I dont have the copy of the batch file in client machiene, but i have mapped to my client machiene.
Thanks again,
Rizly

Similar Messages

  • How to invoke the .bat(batch file ) from the java program

    i want to run some commands when i run one java program.
    I wrote those dos commands on the batch file and i want to include the bat file in the java program so that i can execute the bat file when i run the java program.
    tell me the way that i can run my bat file inside the java program.

    i tried this :
    a .bat file named test.bat, with this code : copy test.bat test2.bat
    a java class, Test.class, in the same directory
    public class Test {
         public static void main(String[] args) {
              try {           
                   Runtime rt = Runtime.getRuntime();
                   Process proc = rt.exec("cmd /c test.bat");
                   proc.waitFor();
                   int exitVal = proc.exitValue();
                   System.out.println("Process exitValue: " + exitVal);
              catch (Throwable t) {
                   t.printStackTrace();
    }

  • Running other binaries or batch files from within java

    Hello,
    I recently inherited several closed-source windows executables. I need to execute them when a user clicks on a JButton. (after which I can parse the text files they generate)
    I realize this will make my application windows-only...
    Does anyone know how I can execute a file (or dos shell commands) from inside java?
    Thank you in advance,
    Andy

    My understanding was the command.com (which isn't an executable, just like dir isn't an executable (not a windows user, doesn't know these things))
    "Not to be confused with OS/2 Warp CMD.EXE, the file CMD.EXE is the Microsoft Windows NT command line shell and is more compatible and portable between different hardware platforms when compared to the original COMMAND.COM, which has been used as the command interpreter with DOS for several years. COMMAND.COM is included for backwards compatibility and is recommended that it be used when old MS-DOS programs may not be able to be run in Windows NT."
    "Apart from what was listed in the opening paragraph, one of the most noticeable things a user is going to notice when using CMD to access MS-DOS is the ability to use long file names. When a user is using COMMAND they will need to use the short 8.3 name. For example, if a user wanted to access "My Documents" in COMMAND they would need to type "cd mydocu~1". However, a user who wanted access the same directory through CMD could type "cd my documents"."
    I believe my legacy software falls in to the category of "old MS-DOS programs" (and the Windows XP kernel is based on NT)

  • Error running batch files from java source file???

    Dear Friends,
    hi,
    this is with response to a doubt i had earlier ,
    i want to run batch files from the java source file ,i tried using this code (here batrun is the batch file name that contains commands to run other java files)
    try
    String [] command = {"c:\\vishal\\finalmain\\batrun"};
    Runtime.getRuntime().exec(command);
    catch(Exception e)
    but i got the following error.
    java.io.IOException: CreateProcess: gnagarrun error= 2
    plz. help me, i tried all combination w/o success,
    in anticipation(if possible give the code after testing)
    Vishal.

    hello there,
    i solved the prob. by using
    cmd /c start filename ,but i need to pass parameters ie
    cmd /c start java "c:/vishal/runfile a b" where a and b are the parameters. but it is not accepting this in Runtime.getRuntime.exec(),
    any solutions ?????????
    regards,
    Vishal

  • How do I make a batch file if the .class file uses a foreign package?

    I am trying to make an MS-DOS batch file using the bytecode file from the Java source file, called AddFields.java. This program uses the package BreezySwing; which is not standard with the JDK. I had to download it seperately. I will come back to this batch file later.
    But first, in order to prove the concept, I created a Java file called Soap.java in JCreator. It is a very simple GUI program that uses the javax.swing package; which does come with the JDK. The JDK is currently stored in the following directory: C:\Program Files\Java\jdk1.6.0_07. I have the PATH environment variable set to the 'bin' folder of the JDK. I believe that it is important that this variable stay this way because C:\Program Files\Java\jdk1.6.0_07\bin is where the file 'java.exe' and 'javac.exe' are stored. Here is my batch file so far for Soap:
    @echo off
    cd \acorn
    set path=C:\Program Files\Java\jdk1.6.0_07\bin
    set classpath=.
    java Soap
    pause
    Before I ran this file, I compiled Soap.java in my IDE and then ran it successfully. Then I moved the .class file to the directory C:\acorn. I put NOTHING ELSE in this folder. then I told the computer where to find the file 'java.exe' which I know is needed for execution of the .class file. I put the above text in Notepad and then saved it as Soap.bat onto my desktop. When I double click on it, the command prompt comes up in a little green box for a few seconds, and then the GUI opens and says "It Works!". Now that I know the concept of batch files, I tried creating another one that used the BreezySwing package.
    After I installed my JDK, I installed BreezySwing and TerminalIO which are two foreign packages that make building code much easier. I downloaded the .zip file from Lambert and Osborne called BreezySwingAndTerminalIO.zip. I extracted the files to the 'bin' folder of my JDK. Once I did this, and set the PATH environment variable to the 'bin' folder of my JDK, all BreezySwing and TerminalIO programs that I made worked. Now I wanted to make a batch file from the program AddFields.java. It is a GUI program that imports two packages, the traditional GUI javax.swing package and the foreign package BreezySwing. The user enters two numbers in two DoubleField objects and then selects one of four buttons; one for each arithmetic operation (add, subtract, multiply, or divide). Then the program displays the solution in a third DoubleField object. This program both compiles and runs successfully in JCreator. So, next I moved the .class file from the MyProjects folder that JCreator uses to C:\acorn. I put nothing else in this folder. The file Soap.class was still in there, but I did not think it would matter. Then I created the batch file:
    @echo off
    cd \acorn
    set path=C:\Program Files\Java\jdk1.6.0_07\bin
    set classpath=.
    java AddFields
    pause
    As you can see, it is exactly the same as the one for Soap. I made this file in Notepad and called it AddFields.bat. Upon double clicking on the file, I got this error message from command prompt:
    Exception in thread "main" java.lang.NoClassDefFoundError: BreezySwing/GBFrame
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
    4)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Caused by: java.lang.ClassNotFoundException: BreezySwing.GBFrame
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    ... 12 more
    Press any key to continue . . .
    I know that most of this makes no sense; but that it only means that it cannot find the class BreezySwing or GBFrame (which AddFields extends). Notice, however that it does not give an error for javax.swing. If I change the "set path..." command to anything other than the 'bin' folder of my JDK, I get this error:
    'java' is not recognized as an internal or external command,
    operable program or batch file.
    Press any key to continue . . .
    I know this means that the computer cannot find the file 'java.exe' which I believe holds all of the java.x.y.z style packages (native packages); but not BreezySwing or any other foreign packages. Remember, I do not get this error for any of the native Java packages. I decided to compare the java.x.y.z packages with BreezySwing:
    I see that all of the native packages are not actually visible in the JDK's bin folder. I think that they are all stored in one of the .exe files in there because there are no .class files in the JDK's bin folder.
    However, BreezySwing is different, there is no such file called "BreezySwing.exe"; there are just about 20 .class files all with names like "GBFrame.class", and "GBActionListener.class". As a last effort, I moved all of these .class files directly into the bin folder (they were originally in a seperate folder called BreezySwingAndTerminalIO). This did nothing; even with all of the files in the same folder as java.exe.
    So my question is: What do I need to do to get the BreezySwing package recognized on my computer? Is there possibly a download for a file called "BreezySwing.exe" somewhere that would be similar to "java.exe" and contain all of the BreezySwing packages?

    There is a lot of detail in your posts. I won't properly quote everything you put (too laborious). Instead I'll just put your words inside quotes (").
    "..there are some things about the interface that I do not like."
    Like +what?+ This is not a help desk, and I would appreciate you participating in this discussion by providing details of what it is about the 'interface' of webstart that you 'do not like'. They are probably misunderstandings on your part.
    "Some of the .jar files I made were so dangerously corrupt, that I had to restart my computer before I could delete them."
    Corrupt?! I have never once had the Java tools produce a corrupt Jar. OTOH, the 'cannot delete' problem might relate to the JRE gaining a file lock on the archive at run-time. If the file lock persisted after ending the app., it suggests that the JRE was not properly shut down. This is a bug in the code and should be fixed. Deploying as .class files will only 'hide' the problem (from casual inspection - though the Task Manager should show the orphaned 'java' process).
    "I then turned to batch files for their simple structure and portability (I managed to successfully transport a java.util containing batch file from my computer to another). This was what I did:
    - I created a folder called Task
    - Then I copied three things into this folder: 1. The file "java.exe" from my JDK. 2. The program's .class file (Count.class). and 3. The original batch file.
    - Then I moved the folder from a removable disk to the second computer's C drive (C:\Task).
    - Last, I changed the code in the batch file...:"
    That is the +funniest+ thing I've heard on the forums in the last 72 hours. You say that is easy?! Some points.
    - editing batch files is not scalable to 100+ machines, let alone 10000+.
    - The fact that Java worked on the target machine was because it was +already installed.+ Dragging the 'java.exe' onto a Windows PC which has no Java will not magically make it 'Java enabled'.
    And speaking of Java on the client machine. Webstart has in-built mechanisms to ensure that the end user has the minimum required Java version to run the app. - we can also use the [deployJava.js|http://java.sun.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html#deplToolkit] on the original web page, to check for minimum Java before it puts the link to download/install the app. - if the user does not have the required Java, the script should guide them through installing it.
    Those nice features in deployJava.js are available to applets and apps. launched using webstart, but they are not available for (plain) Jar's or loose class files. So if 'ensuring the user has Java' is one of the requirements for your launch, you are barking up the wrong tree by deploying loose class files.
    Note also that if you abandon webstart, but have your app. set up to work from a Jar, the installation process would be similar to above (though it would not need a .bat file, or editing it). This basic strategy is one way that I provide [Appleteer (as a downloadable ZIP archive)|http://pscode.org/appleteer/#download]. Though I side-step your part 1 by putting the stuff into a Jar with the path Appleteer/ - when the user expands the ZIP, the parts of the app. are already in the Appleteer directory.
    Appleteer is also provided as a webstart launched application (and as an applet). Either of those are 'easier' to use than the downloadable ZIP, but I thought I would provide it in case the end user wants to save it to disk and transport the app. to a machine with no internet connection, but with Java (why they would be testing applets on a PC with no internet connection, I am not sure - but the option is there).
    "I know that .jar and .exe files are out because I always get errors and I do not like their interfaces. "
    What on earth are you talking about? Once the app. is on-screen, the end user would not be able to distinguish between
    1) A Jar launched using a manifest.
    2) A Jar launched using webstart.
    3) Loose class files.
    Your fixation on .bat files sounds much like the adage that 'If the only tool you have is a hammer, every job starts to look like a nail'.
    Get over them, will you? +Using .bat files is not a practical way to provide a Java app. to the end user+ (and launching an app. from a .bat looks quite crappy and 'second hand' to +this+ user).
    Edit 1:
    The instructions for running Appleteer as a Jar are further up the page, in the [Running Appleteer: Application|http://pscode.org/appleteer/#application] section.
    Edited by: AndrewThompson64 on May 19, 2009 12:06 PM

  • How could I have a VI execute a DOS batch file?

    I need to update the PC's hardware timeclock and the Windows clock via a VI front panel. If I can update hardware and windows timeclocks from a DOS prompt (TIME/NEW TIME), is there a way to provide a LV interface for the same operation? If a VI could run a DOS batch file, having the operator enter a new time in a DOS prompt window is the next best thing.
    Thanks,
    Jeff Bledsoe
    Jeffrey Bledsoe
    Electrical Engineer

    tst wrote:
    The syntax is that of the operating system.
    Have you tried right clicking the VI and selecting Help?
    I found the online example by selecting help. I'm using LV 5.1 and I've noticed that offline help is not as detailed as it is with LV 7 Student Edition (I have student edition at home).
    In my latest attempts, I have the string "command.com /c time" wired to the command line input of system exec.vi. I get the dos prompt and a request for a new time.
    To avoid the operator having to enter the time in the DOS window, I tried passing carriage returns and a time update value in the command line input. It didn't work. Do I have to add a system exec.vi for each command line entry and concatenate the vi's somehow?
    Thanks,
    Jeff
    Jeffrey Bledsoe
    Electrical Engineer

  • How can I execute a batch file from my java program

    Hi,
    Can someone help me or direct me to a link,
    How can I execute a DOS batch file from my java program?
    Thanks

    You will need to grab a handle to the process's
    outputstream so u can see its output.The OP didn't mention any output from any batch file;
    nor any input for that
    matter,so lets not complicate matters here for now
    ok?Actually I think this is essential to see whether it works or not. It's either that or do some manual check to see whether it ran, which is not exactly elegant, and in some cases this may not be easier than simply writing the output stream code, or in fact it may be impossible to check manually.
    I'm sure it wasn't intentional that your post appeared to be bristling with attitude.

  • How do I stop ODI if my DOS BATCH file flags an error?

    I have a DOS batch file as the first step in my ODI package. How do I send a code to ODI to tell it that it has failed and to stop processing the rest of the package? I was told I could use an ODI variable to accomplish this but not sure how.
    Also, how do I pass a semaphore/flag an error in my DOS batch file to ODI ?
    Thanks in advance for your help.
    I tried to search for this info in John's blog: http://john-goodwin.blogspot.com/search?q=error
    but was not able to find it.
    :)

    In your package 1st step is OS Command then some other steps involved, right ?
    In that case you can have your package like this
    OS Command (first step) ---------OK--------------> 2nd step -------------------> 3rd step
    So your 2nd step will run only when the 1st step is successful, it will not start 2nd step as 1st itself has failed .
    Thanks,
    Sutirtha

  • DOS batch file

    Hi techies,
    Is there any way we can execute Ms-DOS batch file from a java program.
    Thanks..

    Runtime.exec("cmd /c thebatch.bat");
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • How to upload file from java client to php

    hi
    i am trying to upload/send a file from client using swing/applet
    and receiving it with php code.
    here is the php code which uploads the post file from the client
    $uploaddir = "/home/raghavendra/Documents/";
    $file = basename( $_FILES["uploadedfile"]["name"]);
    echo "file:\n".$file;
    $uploadfile = $uploaddir. $file;
    if (move_uploaded_file($_FILES["uploadedfile"]["tmp_name"],$uploadfile)) {
    echo "File is valid, and was successfully uploaded.\n";
    else {
    echo "File upload failure Possible file upload attack!\n";
    and corresponding different java code which post the
    1)
    public void postmethodTest(String filefrom){
    try{
    String hostname = "localhost";
    int port = 80;
    InetAddress addr = InetAddress.getByName(hostname);
    Socket socket = new Socket(addr, port);
    // Send header
    String path ="/php_prgs/var/www/nsboxng/htdocs/tryupdate.php";
    File theFile = new File(filefrom);
    System.out.println ("size: " + (int) theFile.length());
    DataInputStream fis = new DataInputStream(new BufferedInputStream(new FileInputStream(theFile)));
    byte[] theData = new byte[(int) theFile.length( )];
    fis.readFully(theData);
    fis.close();
    DataOutputStream raw = new DataOutputStream(socket.getOutputStream());
    Writer wr = new OutputStreamWriter(raw);
    String command =
    "POST "+path+" HTTP/1.0\r\n"
    + "Content-type: multipart/form-data, boundary=mango\r\n"
    + "Content-length: " + ((int) theFile.length()) + "\r\n"
    + "\r\n"
    + "--mango\r\n"
    + "content-disposition: name=\"MAX_FILE_SIZE\"\r\n"
    + "\r\n"
    + "\r\n--mango\r\n"
    + "content-disposition: attachment; name=\"datafile\"" ;
    String filename="test.doc\"\r\n"
    + "Content-Type: text/doc\r\n"
    + "Content-Transfer-Encoding: binary\r\n"
    + "\r\n";
    wr.write(command);
    wr.flush();
    raw.write(theData);
    raw.flush( );
    wr.write("\r\n--mango--\r\n");
    wr.flush( );
    BufferedReader rd = new BufferedReader(new
    InputStreamReader(socket.getInputStream()));
    String line;
    while ((line = rd.readLine()) != null) {
    System.out.println("out"+line);
    wr.close();
    raw.close();
    socket.close();
    } catch (Exception e) {System.out.println(e.toString());}
    2)
    public void postMethod(String strURL, String filefrom){
    try {
    String fname = filefrom.substring(filefrom.lastIndexOf("/")+1, filefrom.length());
    File input=new File(filefrom);
    // Prepare HTTP post
    PostMethod post = new PostMethod(strURL);
    // Request content will be retrieved directly
    // from the input stream
    // Per default, the request content needs to be buffered
    // in order to determine its length.
    // Request body buffering can be avoided when
    // content length is explicitly specified
    post.setRequestEntity(new InputStreamRequestEntity(new FileInputStream(input), input.length()));
    // Specify content type and encoding
    // If content encoding is not explicitly specified
    // ISO-8859-1 is assumed
    //post.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1");
    post.setRequestHeader("Content-Type","multipart/form-data");
    post.setRequestHeader("Content-Disposition", "form-data; name="+fname);
    // Get HTTP client
    HttpClient httpclient = new HttpClient();
    // Execute request
    try {
    int result=httpclient.executeMethod(post);
    // Display status code
    System.out.println("Response status code: " +result);
    // Display response
    System.out.println("Response body: ");
    // System.out.println(post.getResponseBodyAsString());
    BufferedReader console = new BufferedReader(new InputStreamReader(post.getResponseBodyAsStream()));
    String name = null;
    String line = null;
    try {
    while ((line = console.readLine()) != null) {
    System.out.println("output"+line);
    //name = console.readLine();
    catch (IOException e) { name = "<" + e + ">"; }
    // System.out.println("Hello " + name);
    } finally {
    // Release current connection to the connection pool
    // once you are done
    post.releaseConnection();
    catch(IOException e){
    but am getting else condition response from php code
    but if i post with html code it is working fine.
    can anybody help me please where i have to change the code
    please suggest me. am in a big trouble and i have to complete this as soon as possible

    One thread is enough.
    http://forum.java.sun.com/thread.jspa?threadID=5198449
    You could have bumped it instead. Also, you still just posted a junk of unformatted stuff. Furthermore, for HttpClient support ask at an HttpClient mailing list of rorum.

  • Running batch files  from Java using exec method

    Hi,
    I want to run a batch file from my Java program like this:
    try {
    Process proc = Runtime.getRuntime().exec("C:\\Refresh.bat");
    catch (Exception e) {
    MessageBox.show(e.getMessage());
    Refresh.bat file contains two commands.
    First one unzips certain zip file.
    Second one refreshes a SQL Server database using osql utility.
    Problem is that when program is run it executes only the first command and hangs on the second one.
    Please help.
    TIA
    Ravinder

    From the FAQ:
    2. How do you launch an external program on a Microsoft Windows platform from a program developed on the Java [tm] programming language?
    The following will launch notepad in Microsoft Windows NT:
    Runtime.getRuntime().exec("cmd /c notepad.exe");
    To launch a program in Microsoft Windows 95/98 use:
    Runtime.getRuntime().exec("c:\\windows\\notepad.exe");
    The Runtime class allows interaction between a program and its environment. The first string command instructs the command line interpretor, cmd to open up the calculator application.
    The exec() methods do not use a shell; any arguments must have the full pathname to the shell as well as the command itself.
    For example, to run a shell on the UNIX� platform, type:
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec("/usr/bin/sh -c date");
    To run a batch file under Microsoft Windows 95/98:
    Process p = rt.exec("command.com /c c:\\mydir\\myfile.bat");
    To run a batch file under Microsoft Windows NT:
    Process p = rt.exec("cmd /c c:\\mydir\\myfile.bat");
    where 'cmd' and 'command.com' are the command-line interpreters for Microsoft Windows machines.
    The Runtime.exec() methods might not work effectively for some processes on certain platforms. Special care should be taken with native windowing, daemon, WIN16/DOS process or some shell scripts.
    regards,
    jarshe

  • Running a windows batch file on the middle teir

    Hi, I am converting a client/server Forms app to 10iAS (9.0.4). in Client Server mode, one of the forms calls a batch file that runs on the client. The same batch file must now run on the middle teir app server where iAS is installed, not the client's computer (no need for WebUtil).
    No change was made to the batch file, and it can be run with supplied params at the command prompt on the iAS server. However, when run through the web app, the batch file is failing. It is being executed, but when it hits this line:
    FOR %%F in (%1\arp*.w) do type %%F | gawk -f ARKeys.awk | gawk -f SMSar.awk
    it fails.
    Q: is there a different method to program DOS batch files wheb being called from the Forms server?

    Hi, I am converting a client/server Forms app to 10iAS (9.0.4). in Client Server mode, one of the forms calls a batch file that runs on the client. The same batch file must now run on the middle teir app server where iAS is installed, not the client's computer (no need for WebUtil).
    No change was made to the batch file, and it can be run with supplied params at the command prompt on the iAS server. However, when run through the web app, the batch file is failing. It is being executed, but when it hits this line:
    FOR %%F in (%1\arp*.w) do type %%F | gawk -f ARKeys.awk | gawk -f SMSar.awk
    it fails.
    Q: is there a different method to program DOS batch files wheb being called from the Forms server?

  • Irregular delay while running a dos batch file using a servlet class

    i used RunTime( ) class to execute a dos-batch file containing some commands like changing the directory, running an exe(executable.exe) file...etc in a servlet class. while this servlet class is invoked, the exe file(executable.exe) is run after irregular delay at different trials.
    Note: When this batch file is run in a stand alone java class, it is working fine.
    what can be the possible cause of this prob? Help me in this.

    It's ok - I've found the answer.
    I'll post it here for anyone else who is interested.
    The problem stemmed from the fact that I had to put the path to javaw.exe in quotes, as the batch file is dynamically generated from the user's environment, and then run. The user's system properties gives a path to java home using a full path name, which WinNT/Win2K doesn't like.
    The following batch file content solves it, closing the DOS box after starting javaw.exe. Before this part of my batch file, there is just some file copying that goes on for the autoupdate process.
    set PATH=%PATH%;"D:\Program Files\JavaSoft\JRE\1.3.1\bin"
    start /B javaw.exe -Dmyapp.home=C:\myapp myapp.client.MyAppClient subSys
    exit
    The parameter subSys is just a command line parameter that MyApp.java looks for, so not relevant for everyone.
    /B prevents a second DOS box from opening.
    exit simply closes the DOS box once the javaw.exe process has started.
    Too easy! Although I can't believe how difficult it was to find information about this. Hopefully it will be of benefit to others.

  • URGENT:- Running a batch file from java program

    Author: pkanury
    I am trying to execute a batch file from my java program using RunTime and Process . It can execute any dos command except for a batch file. Can anyone throw
    some light ?? My code looks like this .....
    cmd = "command.com /c X:\\grits\\scripts\\test.bat"; Runtime rt = Runtime.getRuntime(); Process p = rt.exec(cmd);
    The weird part is that p.waitFor() returns a status of 0 implying that the cmd has been executed successfully. But that is not the case. And my batch file is as simple as - type "ADADA" > junk.txt
    Any help would be appreciated.

    I think it should work when you use a String[] array
    instead of a single String:
    String[] cmd = { "command.com", "/C", "D:\\batch\\do.bat" };
    Note: If the batchfile creates any output (i.e. files),
    they will be stored in the directory of the application
    which calls the batch file, not in d:\batch\...

  • Run a batch file from demantra workflow

    I am trying to run a batch file from demantra's workflow by creating an executable step.
    I am getting the following error.
    Error description ’’Invalid command line:’’"D:\Oracle Demantra Spectrum\Collaborator\demantra\sop\populate_staging.bat"
    I am giving the following value in command line of executable step.
    "#application_root#\sop\populate_staging.bat"
    The batch file exists in the appropriate folder.
    Following code is in the batch file.
    sqlldr userid=msdem/msdem@demsbx control=load_item_hier.ctl
    Please help me.
    Thanks

    This should work for you-
    Create a batch file on your current server (ODI) and write in the path to the other batch file on the other server.
    //Server2completename/D$/Path/yourbatchfile.bat
    From ODI call your batch file that you created on the same machine.. which will inturn call the other batch file on a different machine to execute batch client.
    Also can you paste the errors that you may be getting.. need to check if you are getting any specific issue related to this.
    Thanks
    Denzz

Maybe you are looking for