Runtime.getRuntime.exec() not working when Tomcat is made a windows Sevice

Hi,
I am working on a web application which launches a exe file on subitting the form. I am using Apache Tomcat 4.0.6 to run the web application. Initially Tomcat was not made a windows service on my machine and when I launch an exe it is launching without any problems. I used the following command to launch the exe file:
<code>
Process p = Runtime.getRuntime().exec("C:\\Program Files\\Mercury Interactive\\WinRunner\\arch\\wrun.exe" + strWROptions);
</code>
The above command launches WinRunner on the local machine.
without using tomcat if I just compile and run a test program with this command, the exe is launching perfectly. But, Once I made tomcat a windows service on my machine the exe is not launching.
Also, a process is being created in the windows task bar named wrun.exe once I submit the form but WinRunner is not lauching on the desktop.
Can any one please help and suggest me.
Thanks,
Ramesh

The version of Java I am using is 1.4.2. Even without
using the string array as you mentioned, the exe
(wrun.exe) is launched on my desktop if I don't run
Tomcat as a windows service. But the problem arises on
making it a service :-(
That is strange because going by the documentation what you have been using should never work. I can't test it though, I'm not on MSWindows at the moment..
Now, when I use this string array convention, I am
getting an error saying "The tool could not launch..
some error occured".
That's not a Java error message, it must come from WinRunner. This means that you have succesfully started WinRunner (great!) but something else is wrong; maybe the parameters you pass to it are incorrect.
How would you run it on the command line? Like this?wrun -t "D:\L5_QE\L5A\Initial" -create_text_report on -runThat line executes the wrun program and passes it five parameters, not three. The first parameter is "-t", the second "D:\L5_QE\L5A\Initial", the third "-create_text_report", the fourth "on", and the fifth "-run". The array of strings that corresponds to that line isString[] command = {"C:\\Program Files\\Mercury Interactive\\WinRunner\\arch\\wrun.exe",
                "-t", "D:\\L5_QE\\L5A\\Initial",
                "-create_text_report", "on",
                "-run"};

Similar Messages

  • Runtime.getRuntime.exec() not working with through Servlet

    Hi ,
    I want to open a IE from servlet,I am using a Runtime.getRuntime.exec to open the browser ,but my servlet is executing but IE is not opening...Here i am using TomcatServer...Is any settings to be Done in TomcatServer.
    My Servlet code is
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException
         String s1 = "C:/Program Files/Internet Explorer/IEXPLORE.EXE";
         String s2 = "http://192.168.0.149:8080/etk/etk3.htm";
         Runtime runtime = Runtime.getRuntime();
         runtime.exec(s1 + " " + s2);
    i know it is contrary to the purpose servlets are meant for.but i am using for different purpose..
    help me on this one...
    Thanks in Advance

    No, I am using the right path, I am sure. Also I tried giving the absolute path of the UserGuide.pdf. Still it cannot find. Please anyone try spawning an application from a different directory and lemme know your openion.
    Regards,
    Thomas.

  • Why is Runtime.getRuntime().exec() not working in JSP?

    Hi all,
    I need to execute a command file from a JSP. I am using Tomcat 4.0.3.
    Here is the code :
    I just wanted to test if this will work, so tried to do run notepad.exe. But in my actual project, i need to run some other commands from a bat file or cmd file.
    <%@ page import="java.util.*,java.io.*,java.net.*" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="tryexec" %>
    //tryexec is a class which has the same java statements as in this jsp
    <%     
    Runtime r = Runtime.getRuntime();
    String s3 = "C:\\WINNT\\explorer.exe";
    String s4 = "C:\\bin\\open.cmd"; //inside open.cmd file , i have "notepad.exe"
    r.exec(s3);
    r.exec(s4);
    /*     tryexec c = new tryexec();
         c.execTo(); // doesn't work
    %>
    I have a html page , when i click a button there , it will call the above jsp , and this jsp will execute the command file.
    If i run the above java statements using a simple java program, it works fine, it opens a notepad and explorer window. but if i do the same thing in jsp, why doesn't it work? Is there any security problem? no exception is shown . Is it a problem with tomcat?
    I also tried to import the java class in jsp and call the function, but still didnt work.
    Please let me know whats the problem, and how to execute command files from jsp.
    Thanks
    Priyha

    It would work with Java coz u r working on the same machine as the java class file.
    While in case of JSP, it is like connecting to a different machine (even if the server is running on the same machine). If you do something like "net send user message" command in JSP or something other executable (just to test), you would see it to work.
    I hope you understand my point here.
    Write back if you have any issues.
    Regards
    Aruneesh

  • Port blocked when Tomcat is made a windows service

    Hi All
    I have a web application which listens on some port for server response .That port gets blocked when Tomcat is made a windows service.But if i run tomcat normally this problem does not occure.So i am not getting what is exact problem?

    Huh?
    As a guess you mean that you when you run Tomcat the server port doesn't work.
    The difference is because in one case you are running as one user and in the other you are running as a different user. On windows you are probably running 'without' a user because you didn't explicitly set one up.
    The solution is to use an explicit user. That is also the way you should test. Log in as that user and run tomcat from the command line as that user.

  • Crystal report not working when setup is made in VS 2010

    Hi, i am new to SAP Business objetcts as well as in this forum.
    I have made an application in VS 2010 (C# /WPF) and made its .exe file too.
    The Crystal reports are working fine when i am running from Visual Studio.
    But it gives error message while i am running the .exe.
    I have made the .exe as normally we do.
    Please help me out.
    Regards.

    Adam assumed you were using Enterprise as the thread was posted to the ".NET - SAP BusinessObjects Enterprise, SAP BusinessObjects Edge, SAP Crystal Reports Server" forum.
    Since you are using WPF viewer, I'm pretty sure this is not the case.
    I am not sure how you are loading the report, so a code snippet from your app will help. Also, in your code as a test, hard code the path to the report. Does that work?
    Looking at the [WPF|http://www.sdn.sap.com/irj/scn/elearn?rid=/library/uuid/a09f7025-0629-2d10-d7ae-df006a51d1a8] demo is going to be worthwhile also.
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup
    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

  • Speech Recognition not working when tested in IE on Windows 8.1

    Hi,
    I have adapted the example code form the Speech Recognition documentation to fire up Speech recognition in Visual Studio for Web Express 2013 on Windows 8.
    The speech synthensizer works fine when I fire up the app in IE and produce Text-to-speech, but when I try the Speech recognition code, all I get is "Waiting for Localhost" messages, and no result.
    Is there a problem with speech recognition with Web development using browsers? (I tried and failed in Opera as well)
    I am keen to use speech recognition for a webapp, ultimately serving mobile devices with the power of server-based processing.
    Anyone help please?

    Hi simulsys,
    I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum.
    If it is related to the Windows Speech Recognition, this forum would be better:
    http://archive.msdn.microsoft.com/wsrmacros/Thread/List.aspx
    Or it is the Speech Server issue:
    http://social.msdn.microsoft.com/Forums/en-US/3ae80ba0-9a35-4457-8d08-a069e1a54506/windows-speech-recognition?forum=whatforum
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Runtime.getRuntime().exec(x) "Command not found"?

    Hello,
    I am attempting to run the following code in my java program.
    System.out.println("<!> gunzip -c " + curZippedFilePath + " | tar xf - --directory " + curMovedUnzippedPath;
    String unzipCommand[] = {"sh gunzip -c " + curZippedFilePath + " | tar xf - --directory " + curMovedUnzippedPath};
                  Process unzipChild = Runtime.getRuntime().exec(unzipCommand);
                 However, when it is run, I get the following message.
    <!> gunzip -c /gnm/apache/htdocs/GNM_Data/1c02.tgz | tar xf - --directory /gnm/GNM_Autoupdate/databaseUpdate/dataDump/1c02
    Exception in thread "main" java.io.IOException: java.io.IOException: gunzip -c /gnm/apache/htdocs/GNM_Data/1c02.tgz | tar xf - --directory /gnm/GNM_Autoupdate/databaseUpdate/dataDump/1c02: not found
            at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
            at java.lang.ProcessImpl.start(ProcessImpl.java:65)
            at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
            at java.lang.Runtime.exec(Runtime.java:591)
            at java.lang.Runtime.exec(Runtime.java:464)
            at DatabaseBackUpdate.main(DatabaseBackUpdate.java:49)Why is the gunzip command not found? Also, the command works when I try it in the shell. Why doesn't it work in the Java code?

    I got it!
    I needed to use the following without passing an array to the exec() function.
    String theCommand = "tar xfz " + curZippedFilePath + " -C " + dataDumpDir;
    Process unzipChild = Runtime.getRuntime().exec(theCommand);No onto another problem : (

  • Unable to execute Runtime.getRuntime().exec(

    Hello,
    I am new to Java programming and trying to execute (OS is Linux) an external jar File with the command:
    Runtime.getRuntime().exec("nohup java -jar SeismicAgents.jar &");It should start the SeismicAgents.jar and write the output to nohup.out.
    This works perfectly if I just enter the command at the command line.
    But upon starting it from within my program, the process seems to be started (I can see it when executin "ps aux"), but it is obviously not running as no input is written to nohup.out and the file which SeismicAgents.jar should generate is not generated.
    I also tried the following code:
    String cmd[] = {"nohup", "java", "-jar", "SeismicAgents.jar", "&"};
    Runtime.getRuntime().exec(cmd);But I am experiencing the same problem here.
    Executing something like
    Runtime.getRuntime().exec(ls);works without problems...
    Can anyone help?

    Runtime.getRuntime().exec("nohup java -jar
    SeismicAgents.jar &");Java does not interprete the '&' character. Neither does
    nohup. You would have to prefix this with /bin/sh -c, put
    the rest in quotes and, most importantly, redirect input
    and output somewhere. Without redirection, it is the task
    of your java program to feed the subprocess with input
    and drain its stdout and stderr buffers.
    Executing something like
    Runtime.getRuntime().exec(ls);works without problems...It is hard to believe this. Either it should be "ls" or
    ls is string variable containing the relevant string,
    but even then I would be surprised if you see any
    output on the command line. At least I don't get
    anything with public class bla {
      public static void main(String[] argv) throws Exception {
        Runtime.getRuntime().exec("ls");
    }If you don't want a "/bin/sh -c" hack, you may want to
    try http://www.ebi.ac.uk/~kirsch/monq-doc/monq/stuff/Exec.html .
    Harald.

  • How to use Runtime.getRuntime().exec() in JSP? is it works in JSP or not

    Hi to all,
    i want run a .exe file from JSP file. In java i am able do this, using Runtime.getRuntime().exec().
    but same thing, when i trying with JSP it is not working?
    plz let me is there any other ways to do it..

    It depends, usually (ie in an J2EE container) you're not allowed to access files or the runtime environment, by definition. What do you wan't to achieve with the exe?
    --olaf                                                                                                                                                                                                                                                                                                                                                           

  • Runtime.getRuntime().exec(cmd) not working

    I have created binary scrip to parse file from one format to another format and the file parser is available on Linux path and working fine when calling from command prompt but while calling this program from jsf or any any java form bean it adds some special charaters with program and throws IOException as belows
    calling command
    String[]     cmd={"delimiter",inputFile.toString(),outputFile.toString()};
    Process     p=Runtime.getRuntime().exec(cmd);
    it gives following error.
    java.io.IOException: delimiter@! : not found
    while calling this from jaav main application working fine.
    any suggestion would be appriciated.
    Cheers,
    dharmendra

    Thanks.
    I printed out whatever values are being passed and it is printing the right values on console and in log file and I also tried this command in stand alone application program an working fine. but when I call it from jsf form bean it adds ^@ at the end of first parameter and says ;
    IOException : delimiter^@ : not found
    i actually created the same copy as delimiter^@ and put it in same path directory with 777 mode.
    and now its working fine. but I did not know the reason why it change the name of first argument.
    Thanks,

  • Runtime.getRuntime().exec("cmd /c start file\\"+"My file.txt" ) Not work

    Hello
    i have a problem I use:
    Runtime.getRuntime().exec("cmd /c start file\\"+"My file.txt");
    to open "my file.txt" And I have error System Windows don't open file file\My becaus file My don't exist When I rename file to "Myfile.txt" and use:
    Runtime.getRuntime().exec("cmd /c start file\\"+"Myfile.txt");
    It's work great. My problem is when my file have space in name or other [ ], etc symbol. How fix this problem?
    Thenks to help:)

    Try using the verson where you specify the parameters in an array as this example shows:
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=635363
    Note: you may need to enclose the file name in quotes

  • Runtime.getRuntime().exec() does not work after JRE upgradation

    I have upgraded JRE from 1.3.0_02 to 1.3.1_15. After this upgrade, Runtime.getRuntime().exec() has suddenly stopped working. If I downgrade to 1.3.0_02, it starts working again.
    Please help.

    It has definitely forked, and this is the child process. It says so. If it was the parent process it would just show Java code related to launching processes. That does not involve PKCS11. After the fork there are two identical processes with the same stack: the child process of the fork goes on to replace itself with the target command via Unix exec(), which it doesn't look like it is succeeding at. The parent process doesn't do much at all, probably just housekeeping and then a Unix wait() for Process.waitFor() to hook into.

  • Access denied when Runtime.getRuntime().exec

    I have an applet that opens a JFrame.
    In the JFrame I have a JButton, when I click the button I want a browser to open with a specific website.
    This doesn't work.
    When I look in the cmd-prompt it says:
    "java.security.AccessControlException: access denied (java.io.FilePermission C:\Program execute)"
    What have I done wrong? Do I have to change the security settings? Where do I that?
    class KnappListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
    frame2 = new JFrame(e.getActionCommand());
    frame2.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {System.exit(0);}});
    String website = new String("http://www.microsoft.com");
    try {
    Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.exe"+website);
    //Runtime.getRuntime().exec("cmd/C"+"start.exe"+website);
    catch (IOException io) {}
    }

    it doesn't matter which class your program extends. if your program is an applet (running in a browser) it is not permitted to use Runtime.getRuntime().exec(). If your program is an application, it is allowed to do so.
    I think there is a way for applets to get the permission through a policy, but I don't know how to do this.

  • Runtime.getRuntime().exec works on windows failed on linux!

    Hi,
    I'm trying to execute a linux command from java 1.4.2 using Runtime.getRuntime().exec(). The linux command produces output and write to a file in my home dir. The command runs interactively in the shell and also run on windows.
    The command is actually a mozilla pk12util. My java code to run this pk12util works on windows, but not on linux (fedora). When I print out the command I'm trying to run in java, I can run it interactively in bash shell.
    Method below is where the problem seems to be:
    public void writeCert() {
    // Declaring variables
    System.out.println("Entering writeCert method");
    String command = null;
    certFile = new File(credFileName);
    // building the command for either Linux or Windows
    if (System.getProperty("os.name").equals("Linux")) {
    command = linuxPathPrefix + File.separator + "pk12util -o "
    + credFileName + " -n \"" + nickName + "\" -d "
    + dbDirectory + " -K " + slotpw + " -w " + slotpw + " -W "
    + pk12pw;
    System.out.println("System type is linux.");
    System.out.println("Command is: " + command);
    if (System.getProperty("os.name").indexOf("Windows") != -1) {
    // command = pk12utilLoc + File.separator + "pk12util -o
    // "+credFileName+" -n "\"+nickname+\"" -d \""+dbDirectory+"\" -K
    // "+pk12pw+" -w "+pk12pw+" -W "+pk12pw;
    command = pk12utilLoc + File.separator + "pk12util.exe -o "
    + credFileName + " -n \"" + nickName + "\" -d "
    + dbDirectory + " -K " + slotpw + " -w " + slotpw + " -W "
    + pk12pw;
    System.out.println("System type is windows.");
    System.out.println("Command is: " + command);
    // If the system is neither Linux or Windows, throw exception
    if (command == null) {
    System.out.println("command equals null");
    try {
    throw new Exception("Can't identify OS");
    } catch (Exception e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
    // Having built the command, running it with Runtime.exec
    File f = new File(credFileName);
    // setting up process, getting readers and writers
    Process extraction = null;
    BufferedOutputStream writeCred = null;
    // executing command - note -o option does not create output
    // file, or write anything to it, for Linux
    try {
    extraction = Runtime.getRuntime().exec(command);
    } catch (IOException e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
    // Dealing with the the output of the command; think -o
    // option in command should just write the credential but dealing with output anyway
    BufferedWriter CredentialOut = null;
    OutputStream line;
    try {
    CredentialOut = new BufferedWriter (
    new OutputStreamWriter(
    new FileOutputStream(credFileName)));
    catch (FileNotFoundException e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
    // writing out the output; currently having problems because I am trying to run
    }

    My error is due to the nickname "-n <nickname" parameter error. I think the problem is having a double quotes around my nickname, but if I take out the double quotes around my nickname "Jana Test's ID" won't work either because there are spaces between the String. Error below:
    Command is: /usr/bin/pk12util -o jtest.p12 -n "Jana Test's Development ID" -d /home/jnguyen/.mozilla/firefox/zdpsq44v.default -K test123 -w test123 -W test123
    Read from standard outputStreamjava.io.PrintStream@19821f
    Read from error stream: "pk12util: find user certs from nickname failed: security library: bad database."
    null
    java.lang.NullPointerException
    at ExtractCert.writeCert(ExtractCert.java:260)
    at ExtractCert.main(ExtractCert.java:302)
    Code is:
    private String nickName = null;
    private void setNickname(String nicknameIn) {
    nickName = nicknameIn;
    // building the command for either Linux or Windows
    if (System.getProperty("os.name").equals("Linux")) {
    command = linuxPathPrefix + File.separator + "pk12util -o " + credFileName + " -n \"" + nickName + "\" -d " + dbDirectory + " -K " + slotpw + " -w " + slotpw + " -W " + pk12pw;
    System.out.println("System type is linux.");
    System.out.println("Command is: " + command);
    extraction = Runtime.getRuntime().exec(command);
    BufferedReader br = new BufferedReader(
    new
    InputStreamReader(extraction.getErrorStream()));
    PrintStream p = new PrintStream(extraction.getOutputStream());
    System.out.println("Read from standard outputStream" + p);

  • Runtime.getRuntime().exec doesn't work

    I write in my program this line:
    p=Runtime.getRuntime().exec("/usr/bin/identify -verbose /tmp/cible.jpg > /tmp/cible.jpg.txt");
    But the file cible.jpg.txt is not created!
    Can you explain me?
    advance thanks!
    Best regards!!!

    It doesn't work because it is literally passing the "> /tmp..." characters as a command-line argument to the "/usr/bin/identify" program, as opposed to having the shell interpreter (which you're not invoking) interpret that to mean "redirect the output to this file".

Maybe you are looking for

  • Batches and Serial numbers

    Hi, How can i create Batches and Serial numbers for a item in inventory in SAP B1

  • Ipod touch flashing screen issue

    I have a 4th gen Ipod touch. A few days ago, a thin red line appeared near the bottom of the screen, about 1/4 of the way up. after a few days, it turned into a white line, and the screen flickers when using it. The line isn't there when I first star

  • On-the-go-List

    Hi, I'm new to apple tv and loving it. Could someone help me with creating my own playlist. I thought I was doing that by using on the go lists, but I don't know how to play any back that I have saved in that section - anyone help me please? Also can

  • Refresh dragProxy in List component built-in drag & drop feature

    Hi, I'm using the built-in drag & drop feature of the List component. Everything works fine except one thing. The itemRenderer I use in my List contains many TextInput that the user can fill. The problem is when I drag an itemRenderer to reorder my l

  • Iphone 6 mobile site set up

    Hello, I have a few question and I was hoping someone could help. My first is what do I set up my mobile site to pixel wise? Apple says is 1334 x 750 would I lay it at half that size and use the HIPD 2X setting to double it? What about the PPI? 326?