Open Batch file during Runtime

How Can i execute a batch file from java program.?
my batch file only have this command """" java Server""""
Server is the name of my java file application.

Runtime.exec() is the thing you want.
BUT before you use it, read this:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps_p.html
and this:
http://mindprod.com/jgloss/exec.html
and, of course, this:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
-T-

Similar Messages

  • How to update cgicmd.dat file during runtime?

    I'd like to know how do update cgicmd.dat file during runtime. For example, I run a report one.jsp as
    http://<machine>:<port>/reports/rwservlet?one.jsp&USERID=uid/pwd@db&DESTYPE=cache&mode=bitmap&desformat=htmlcss
    within this report there is a hyperlink to open another report named two.jsp.
    before creating this hyperlink, I'd like to update cgicmd.dat file with passed in userID, pwd, and connection, so two.jsp can use this key for userinfo
    so I can create hyperlink as follows
    srw.set_hyperlink('/reports/rwservlet?report=two.jsp'||
    '&cmdkey=userinfo&DESTYPE=cache&mode=bitmap&desformat=htmlcss');
    Thanks

    To my knowledge the cgicmd.dat is only read when the OC4J starts, so you would have to come up with another solution. Using Single-Sign-On (SSO) is quite a good idea, and it's there for cases like this.
    Regards,
    Martin Malmstrom

  • I Can't Open Batch Files

    I Can't Open Batch Files
    I go to open a batch file and an error message comes up saying "Windows cannot find "C:\Users\User\Desktop\(My Batch File).bat"
    I really have no clue how to fix it.
    For some reason when I go on run and search "cmd" nothing comes up and it says again "Windows cannot find....."
    I only have cmd in my documents now. 
    I'm not sure if this is connected but hopefully someone will know the answer.

    Hi Joshrob,
    Have you installed any software or made an modification to this machine?
    Please take the following steps to have a troubleshoot :
    1.Run the antivirus software to have a full scan of the system.
    2.Open the registry editor and check whether there is a registry key called “DisableCMD” and if it is there , please set its value as “0”.
    3.Check the existence of “cmd.exe” in  this path C:\Windows\System32.If it is there ,run it directly to have a check .If it is not presented ,you may need to copy one from another machine or perform a system restore to recover
    the system to a previous normal point.
    Best regards

  • Executing Batch files from Runtime.getRuntime().exec

    Can we execute batch files from Runtime.getRuntime().exec() method.
    Regards,
    Nalini

    hi,
    import java.io.IOException;
    class BatchFileTest{
         public static void main(String args[]){
              try{
              Runtime r = Runtime.getRuntime();
              Process p = r.exec("startcmd.bat");
              catch(IOException en){
                   en.printStackTrace();
    -Regards
    Manikantan

  • Problem wiht Running Batch File using Runtime.exec()

    I am writting one program which will create a jar file using a windows Batch file.
    The main program is in the folder "d:\CmdExec.java".
    The other one to which a jar file to be created is in the folder "e:\folder\HelloWorld.class"
    The contents inside the "e:\folder" are
    e:\folder\HelloWorld.class
    e:\folder\mainClass.txt
    e:\folder\run.bat
    The mainClass.txt contains "Main-Class: HelloWorld"
    The Run.bat file contains "jar cmf mainClass.txt HelloWorld.jar *.class"
    The coding for CmdExec.java is as follows
    import java.io.*;
    import java.awt.Desktop;
    public class CmdExec {
    public static void main(String argv[]) {
    try {
    Desktop desktop = null;
    if (Desktop.isDesktopSupported()) {
    desktop = Desktop.getDesktop();
    desktop.open(new File("e:\\folder\\run.bat"));
    catch (Exception err) {
    err.printStackTrace();
    When i double click the file e:\folder\Run.bat, it will create a jar file for HelloWorld.class.
    But, i want to create that jar file using the java program CmdExec.java.
    When i run CmdExec.java, the batch file is opened. But it shows error as "Can't find the specified file"
    But when i copy the following files to "d:\",
    e:\folder\HelloWorld.class
    e:\folder\mainClass.txt
    the jar file is created using the CmdExec.java.
    But,
    e:\folder\HelloWorld.class
    e:\folder\mainClass.txt
    these files should be in the folder"e:\folder" only.
    Can anyone Help me this Problem?
    Or Anyother way for creating a jar file for one program by using another program?
    Help me soon.............

    Try this. It's not running a bat file. You can say it almost is a bat file.
    import java.io.*;
    import java.util.Scanner;
    public class CmdExec {
        public static void main(String argv[]) {
            try {
                Process p = Runtime.getRuntime().exec("jar cmf mainClass.txt HelloWorld.jar *.class");
                Scanner s1=new Scanner(new InputStreamReader(p.getInputStream()));
                while(s1.hasNextLine())
                    System.out.println(s1.nextLine());
                p.waitFor();
                System.out.println(p.exitValue());
                if(p.exitValue()==0)
                    System.out.println("Okay");
                else
                    System.out.println("Error");
            catch (Exception ex) {
                ex.printStackTrace();
    }Run it in the same folder as mainClass.txt
    Edited by: ColacX on Aug 1, 2008 10:35 AM

  • Opening a file via Runtime.exec() on Mac OS X

    I'm having a hard time opening a file programatically on Mac OS X.
    The following code works only if the filepath/filename doesn't contain a space:
    String filepath;
    Runtime rt = Runtime.getRuntime();
    rt.exec( "open " + filepath);From a terminal, typing open + surrounding the filepath with either apostrophes or quotes and OS X will open the file no problem, even if it has spaces.
    So I tried modifying my call:
    filepath = "\"" + filepath + "\"";
    rt.exec( "open " + filepath);...then nothing happens. No error, no popup, no exception thrown...nothing. Same thing if I use apostrophes vice quotes.
    Any ideas? I'm using JDK 5.0 as 6.0 is not yet supported by Apple.
    Thanks in advance.

    assuming open is an app, not a command within a shell... what about this:
    String[] cmd = { "open", filepath }; // with out quotes
    rt.exec(cmd);

  • How to run a Jar file during runtime

    Runtime.getRuntime().exec("javaw -jar MYJAR.jar");was what I used to run the jar originally, and it worked. Recently I created an installer for my program, where the user runs a batch-file shortcut which launches the main application. Because the main application is launched from the desktop, rather than directly, the "user.dir" property is different which makes the above code not work. How do I get the name of the folder that contains the running java application?
    Thanks

    You don't. You fix the installer so that it puts the correct working directory into the shortcut that it creates.

  • Load file during runtime

    Is it possible to open a local file at runtime? If so, how?
    Ex: load "C:\myAnimation.swf" and display it.
    Thanks

    I have no lingo nor director experience but I tried your
    solution. However it returns a script error saying the filename
    property was not found.
    I dragged an swf to the stage, named it "DummySwfMember" and
    put the script in the frame.
    What went wrong?

  • Opening BATCH file through custom file extension

    I have a situation where I've created my own filetype (.gme) to open my main java file. Each filetype has a corresponding ID which tells the application what instance of it to load. I want the file type to open a batch file which will in turn open the application. Is there code that I can give a custom file extension to open a batch file?

    Check the permissions of that batch file.
    It should be executable for the PI user (<sid>adm in Unix)
    Regards
    Stefan

  • I can't open batch files in windows 8.1

    I am trying to run a batch file in windows 8.1, when i run the batch file runs at first but closes so fast that you can't see its contents, you can't even see if its doing what you tell it to. Since the file does run but closes fast, i thought of adding
    pause. Adding pause did not fix the problem. I am not sure if i have to change my keys on regedit, or i have some kind of malicious software  that needs to be fixed  ( I think i have no malicious software, i  have run security scan many times
    nothing showed up, I had a Trojan horse, Trojan.Gen2, long time ago but the Trojan got quarantined?) I originally had windows 8 but upgraded to windows 8.1. 
    Help Please! I don't Know what to do!!!

    Hi Glogikon,
    "I am trying to run a batch file in windows 8.1, when i run the batch file runs at first but closes so fast that you can't see its contents, you can't even see if its doing what you tell it to."
    According to my experience ,it is a normal symptom .Did the bat file run well before ?
    Have you tried to run the command one by one in the bat file from a command line ?Have you tried to run the other bat files which including a output to have a check ?
    If it is possible ,please post the command of the bat file here .We will make a test for you .
    To check whether the bat run well ,this link may be useful:
    check if command was successfull in a batch file
    http://stackoverflow.com/questions/14691494/check-if-command-was-successfull-in-a-batch-file
    " I think i have no malicious software, i  have run security scan many times nothing showed up,"
    We can try to work with the following official free tool to have a check .It is recommended to run it in a safe mode to improve the quality of the scanning.
    Malicious Software Removal Tool
    http://www.microsoft.com/security/pc-security/malware-removal.aspx
    NOTE: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites.
    Best regards
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Problem opening a file from Runtime.exec()

    hi
    I'm trying to open a certificate (.cer), from my java code.
    If I go on a windows command, and I type only the name of my certificate ( f:\certificate.cer), it is opened.
    If I use the java code
    Process process = Runtime.getRuntime().exec("F:\\certificate.cer");it doesn't work:
    java.io.IOException: CreateProcess: "f:\oid.crt" error=193
    anybody knows what I can do to make it work?
    Thanks in advance
    Philippe

    For windows you need to used the cmd.exe to do what you want.
    i.e. cmd /c f:\certificate.cer
    Process process = Runtime.getRuntime().exec("cmd.exe /c F:\\certificate.cer");At a command prompt, for more help on cmd.exe type: cmd /?
    Also for help on a related command, type: start /?
    Also read http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Update war files during runtime....

    The Weblogic Server takes a long time to start and stop. So, whenever we make any changes to our application, which is later bundled into a war file, we always have to stop and start the server, so that it loads the new war file. IS there any way to configure the weblogic server to automatically reload the new war file instead of restarting the server again ?
              Any help is appreciated ...
              Thanks
              Kuntal
              

              How about undeploy and "deploy" the war files using the console?
              

  • Adobe reader 11 Hang during 1-2 minutes when opening a file

    Hello,
    We are very unhappy with Acrobat Reader. We have Some Hangs/Crash into us computers.
    With adobe acrobat reader upper tan 11.0.3  hang when start (open a file) during... approx 2 minutes.  During the Hang, Acrobat Reader be unresponsive.
    I tried to change the protected mode. change nothing. I can saw is when Acrobat Reader start the Tools Menu (for me).
    I tried to completely uninstall(registry and folders cleanup too) and do a fresh install, changed nothing.
    If we use 11.0.3 or 10.0.X, we don't have problems.
    Maybe the UTM firewall block something ?
    I need help, why i think we going to use Foxit if we don't fund the problem.
    Best Regards
    Vincent

    Hello,
    No, i checked. I bypassed the UTM Firewall and do same.  
    Yes, I can contact the cloud.acrobat.com, with or without firewall.
    I bypassed the Anti-Virus, same problem.
    I unchecked the "enable protection mode". Same.
    I modified the registry to be like this :
    64-bit:
    Keypath:          HKLM\SOFTWARE\Wow6432Node\Policies\Adobe\Acrobat Reader\11.0\FeatureLockDown
    Value name:   bProtectedMode
    Value type:     REG_DWORD
    Value data:     0
    32-bit:
    Keypath:          HKLM\SOFTWARE\Policies\Adobe\Acrobat Reader\11.0\FeatureLockDown
    Value name:   bProtectedMode
    Value type:     REG_DWORD
    Value data:     0
    [HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\11.0\IPM]
    "bDontShowMsgWhenViewingDoc"=dword:00000001
    "bShowMsgAtLaunch"=dword:00000000
    I saw one way to investigate !    We got a shortcut here  (power injection tests) and the network switch goes off. During the network was disconnected, the Reader work. (Only a little hang of 1-2 seconds during opening file instead the 3-5minutes Hang ). I successfully reproduce them simply with disable the network card.
    Please Adobe Team : Help me to investigate, to debug.
    I saw nothing bad with ProcessExplorer. I do a minidump.
    Which tool I can use to understand ?    Wireshark ?  

  • Two questions: Executing batch files and executing a JAR on boot-up.

    I'm working with Windows XP and and currently I'm having a friend test this on Vista as well. I can't seem to find how to execute a batch file using Runtime.exec(). So far I've been passing the absolute pathname of the batch file as the argument to exec(), but it doens't seem to run, so I'm assuming there's another way.
    Second question, how do I get a JAR file to start running whenever the user turns on the PC?
    Thanks.

    I'm working with Windows XP and and currently I'm
    having a friend test this on Vista as well. I can't
    seem to find how to execute a batch file using
    Runtime.exec(). So far I've been passing the
    absolute pathname of the batch file as the argument
    to exec(), but it doens't seem to run, so I'm
    assuming there's another way.Are you using just Runtime.exec() or have you tried Runtime.getRuntime().exec()? If not, try that and see what happens.
    Second question, how do I get a JAR file to start
    running whenever the user turns on the PC?As far as I know, you can't do that programatically. You have to edit settings on your computer but I am not entirely sure.
    Thanks.

  • Opening a file by double clicking it

    I have a table in which I have a list of some files. When I double click the file I have to open the file from a specified path. Presently I have written the following code which successfully opens the file.
    Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL \""+fileName+"\"");
    But the above code can be run only in windows. Is there any other way which is platform independent to open the files?

    Well, with JavaSE 6 you could use java.awt.Desktop I think:
    http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html
    -Puce

Maybe you are looking for

  • How to display attributes as keyfigures in a report?

    hi experts,                i have a master data like ID is ref.char., under the ID attributes are NET and GROSS, when i am generating the report or query these two attributes ( NET and GROSS) should display as keyfigure which means we can drag these

  • [Solved] Python: Creating AUR package, binary can't find python module

    I'm building a PKGBUILD for PyLotRO for the AUR and I'm using a Debian package.  I tried just copying the content of the data.tar.gz to the filesystem assuming the directory structure is the same for the packages but apparently it is not.  At least I

  • Problems getting a higher framebuffer refresh rate

    Hello everyone just changed from Gentoo to Arch    Anyway here is my problem, I usually use a framebuffer resolution of 1280x1024-32@75. I used to use a Nvidia BFG Geforce Ti4200SE 128MB and it had no problem of booting into the above resolution. I r

  • Windows 2008 failover clustering fails with Event ID 1205 1069 1558

    I have a two nodes Windows 2008 and SQL 2008 cluster running in active\passive.  I was restarting my nodes after applying windows update then I received the following error message below within Failover Cluster Manager. I get errors with Event ID 120

  • Why is the Planned quantity in MCP9 not appearing(Repetitive Manufacturing)

    Sub:WHY IS THE PLANNED QUANTITY IN MCP9 NOT APPEARING(REPITITIVE MANUFACTURING Why are the planned orders not displayed anymore. They are still in the system - in  MD04 - but since we moved from release 3.1i to 4.0 the plan order qty disappeared  fro