Why is getRuntime.exec() in jsp not working?

Hello, could someone help me on the following problem?
I have a jsp program which runs on tomcat server. In the jsp code, I am supposed to execute something. So I wrote the following codes:
<%
Runtime a = Runtime.getRuntime();
java.lang.Process P = a.exec("javac Sieve.java");
if(P.waitFor()!= 0)
String s="Error while compiling";
else
String s="Commang get excecuted succesfully";
%>
It gives me the "Command exceduted successfully", but I couldn't find the Sieve.class file in the current directory. Also, if I change Sieve.java to S.java which doesn't exist, it gives me "error whild compliling". So I assume the command is executed. But where is the class file it produces? Can anyone help me?

If you click on warnerj's profile, you'll see that he's piled up a pretty impressive number of Dukes. He's helped a lot of people, and the Dukes account is proof of that.
IMO, it's not a matter of warnerj having too high an opinion of himself. He's simply telling posters that their chances of getting his (proven) assistance are diminished by cross-posting, because he considers it rude.
Anyone posting a question here depends on the good will of volunteers for answers. warnerj is giving them a lesson in manners that will maximize their chances of getting a solid answer from someone like him. It's in the OP's self-interest to not cross-post.
You're right - there are a lot of people who read these forums who can offer "advice". Lots of them are also chuckleheads. All advice isn't equal. I see a lot of answers that are misleading at best and just plain wrong at worst. I also see some names that I've started to associate with solid advice. Why alienate the good advisers needlessly by cross-posting?
Sun's rules and the etiquette of behavior acceptable by the community here are two different things. warnerj is providing the OP a lesson in the behavior acceptable to this community. Nothing wrong with that. It's more good education, in my view. - MOD

Similar Messages

  • Why iPhone 6 Plus sound microphone not working, but in the case of sound recordings in conversation mode work?

    Why iPhone 6 Plus sound microphone not working, but in the case of sound recordings in conversation mode work?

    Sighhhh, wasted so much time yesterday and today going around Sony centre and then carphone warehouse. They told me to come back after Easter.
    I came home, banged the phone against the wall and it worked.
    Turned out that mic was working on loud speaker and when using headphones so I thought that the secondary mic is working and the main one (placed with the speakers) isn't. So I banged that part against the wall slightly (in plastic case to prevent scratches) then put the phone underwater, waited for it to dry and now it's working. Idk how well and if it's of perfect quality again but people can hear me well.

  • Why is my apple ID password not working on ipad2 after updating to iOS6?

    Why is my apple ID password not working after upgrading to iOS6?

    Who knows?
    Settings>iTunes and App Stores>Tap your ID and sign out. Reboot your iPad.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    Go back to the settings and sign back in again and see of it works now.
    If it doesn't work, post back with some information that might help us help you. Describe what you are doing in some detail and it might let us better understand why this is happening.

  • Why Does Live View In DW Not Work With BC Template?

    The live view using a BC template in DW CS6 shows "PAGE NOT FOUND" in the body section but the header and footer look fine. I should also point out that the index.htm page works fine, it's just the other pages that have this problem. What makes it weirder is that the site works fine in all other modes including when viewing in a normal browser, it's ONLY when in live view! I also noticed that if I delete the .htm extension in the url in the DW browser when in Live View it fixes the problem, but this requires me to do this everytime I want to switch to live view and surely is either a problem with how the BC template files are named or DW CS6 is buggy? Hopefully this is an easy one to answer??

    Hi Alex,
    Thanks for your reply, I have done a video demo at http://screencast.com/t/RsutrvoFn0xZ
    Date: Thu, 14 Feb 2013 05:49:55 -0800
    From: [email protected]
    To: [email protected]
    Subject: Why Does Live View In DW Not Work With BC Template?
        Re: Why Does Live View In DW Not Work With BC Template?
        created by Alex Pavelescu in Dreamweaver & Business Catalyst - View the full discussion
    Hi, Please provide the site url, and if you can, a video demo of the issue you're facing, using http://www.techsmith.com/jing.html, where you could also display the way you have your side setup ( Dreamweaver menu > Site > Site manager > http://screencast.com/t/GqqBk9MY4ck ) Kind Regards,Alex
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5072585#5072585
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5072585#5072585
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5072585#5072585. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Dreamweaver & Business Catalyst by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Why is my secondary click is not working on the right?

    why is my secondary click is not working on the right?

    system preferences/Trackpad/point and click
    check and uncheck secondary click or alter method
    Try SMC reset
    http://support.apple.com/kb/HT3964
    Pram Reset
    http://support.apple.com/kb/ht1379

  • Why does my printer HP 3080 not work with Mac OS X VERSION 10.7.5

    Why does my printer HP 3080 not work with Mac OS X VERSION 10.7.5. Am I missing a driver? If so where do I go to download it? thanks

    What's the full model number and name of the printer?  I can't seem to find any HP printer with the numbers 3080 in the model number.
    How are you connecting the printer to the Mac?
    I am a printer tech for HP.

  • Why does my camera connection kit not work with my ipad 1 after updating on ios 5?

    Why does my camera connection kit not work with my ipad 1 after updating on ios 5? What can I do to make it work again?

    It should. It will only respond if there's something on the card for it to respond to, so do you have pics on the card?
    And if it's messing up; try giving the iPad a restart. Hold down the sleep and home keys, past when you see hte red power down slider and until you see the silver apple. Let it reboot and try again. That can clear up any glitches on the device itself.

  • Why does Corel Suite 10 does not work with Lion OS?

    Why does Corel Suite 10 does not work with Lion OS?

    Either it's incompatible or it's a PPC-only application. PPC applications are no longer supported in Lion because there is no longer a Rosetta emulator. Contact Corel for support.

  • Why does my digital AV adapter not work with my iPad

    Why does my digital AV adapter not work with my iPad

    i was going to try it on a flat screen hdmi input, but just as i plug the apple digital av adapter in to my ipad it says "this accessory is not supported by ipad"... my itouch says the same thing... any ideas?

  • Why is my touch screen function not working when using facetime

    Why is my touch screen function not working when using facetime

    Hello megascones,
    After reviewing your post, it sounds like the screen is not responding to touch in one app. I would recommend that you read this article, it may be able to help the issue.
    If the screen on your iPhone, iPad, or iPod touch doesn't respond to touch - Apple Support
    Restart your device. If you can't restart, reset your device.
    Thanks for using Apple Support Communities.
    Have a nice day,
    Mario

  • Why the alternate audio in netflix not working?

    why the alternate audio in netflix not working? Apple Mexico

    Maybe because your TV can't decode it?
    Do you know if it's another language track in stereo or Dolby Digital 5.1?
    AC

  • I updated my browser to the last versoin of firefox (31). But I have a problem with mozilla. why tha toolbar of alexa does not work on it?

    Hello...
    I updated my browser to the last versoin of firefox (31). But I have a problem with mozilla. why tha toolbar of alexa does not work on it?

    After a quick search in the addon.mozilla.org page, it looks like that add on is still compatible with version 31. Please try to [[Re-enable add-ons that were disabled when updating Firefox]] or make a back up of the add on folder in the profile folder and reinstall the add on. [[Back up and restore information in Firefox profiles]]

  • 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.exec()  in Java not working in Oracle 10 Application Server

    Hi ,
    I am trying to call a .exe file which is in the Web Application folder .
    I am Using Process p = Runtime.exec("path to .exe file ")
    This code is working fine when used with JBOSS , but not working with Oracle Application server .
    Please tell me whether i need to do any chnages to make it work
    Thanks in advance .

    I ran a quick test with your code, I just had to make some small changes, and things work for me...
    I'm testing with JDeveloper 10g 10.1.3.2.0 ...
    The only thing I wonder is DBUser DBPass DBHost, those are not the actual values, correct?, neither they are environment variables?...
    In the server hosting your OAS, you should try running the whole CMD line from the start/run dialog ... make sure it works in that server ...
    Here is the code used in my test:
    In JSP:
      <%@ page import="runexepkg.*" %>
      <% 
      String msg = "";
      try
      RunEXE p = new RunEXE();
      msg = p.main1();
      catch(Throwable t)
         System.out.println("Exception Raised");
         t.printStackTrace();
      %>
      <%= msg %>In Java Class:
    package runexepkg;
    import java.sql.*;
    public class RunEXE
        String ss="";
        public String main1()
        try
            Runtime rt=Runtime.getRuntime();
            Process p = rt.exec("CMD /C start C:\\oraappserver\\j2ee\\WebGis\\applications\\PowerGis\\web\\WEB-INF\\classes\\GisProject\\cust_data_1.exe DBUser DBPass DBHost");
            System.out.println("Command has been executed");
            Class.forName("oracle.jdbc.driver.OracleDriver");
            Connection con = DriverManager.getConnection("jdbc:oracle:thin:@DBHost:DBPort:orcl","DBUser","DBPass");
            System.out.println("Test Connection ========== "+con);
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery("SELECT SYSDATE FROM DUAL");
            if(rs.next())
                ss="Command has been executed - Database has been accessed";
            else
                ss="Command has been executed - Database was not accessed";
        catch(Throwable t)
            System.out.println("Exception raised, command has NOT been executed");
            ss="Exception raised, command has NOT been executed";
            t.printStackTrace();
        return ss;
    }Edited by: Rodolfo Ferrari on Jul 23, 2009 10:40 PM

  • Runtime.getRuntime().exec() in JSP - Starting a batch

    Hi,
    I am trying to start a batch from a jsp in the following way:
    try{
    String path = "bat/drucken";
    ProcessBuilder processBuilder = new ProcessBuilder(path);
    Process process = processBuilder.start();
    out.println("<script type=\"text/javascript\">alert('ausgeführt.');</script>");
    }catch(Throwable t){
    t.printStackTrace();
    out.println("<script type=\"text/javascript\"> alert('Fehler beim Drucken.');</script>");
    But onfortunately it does not work the way I want.
    If I double click the batch file, it works properly and starts a visual basic script, that makes out of n word-documents one single one.
    If I start it like above, then nothing happens and just the alert('ausgeführt') appears.
    How can I start a VB script or a commands of the shell from inside a jsp ?
    PS: using Windows XP, jsp should work on a Windows Server

    As Liane said, this should NOT be in your JSP. This should be in a normal Java file, compiled to a class, in a package, and deployed in the Web Application's /WEB-INF/classes/ directory.
    Example. Change the code to this:
    //Put your class in a package
    package debbie.in.florida;
    import java.io.*;
    public class Console{
        String error = null;
        String output = null;
        public String getError(){
            return error;
        public String getOutput(){
            return output;
        /** Called from inside the jsp like new Console().exec("cscript drucken.vbs param1 param2") **/
        public void exec(){
            try{
                String osName = System.getProperty("os.name" );
                String[] cmd = new String[3];
                cmd[0] = "cmd.exe" ;
                cmd[1] = "/C" ;
                cmd[2] = "Test.exe";
                Runtime rt = Runtime.getRuntime();
                System.out.println("Execing " + cmd[0] + " " + cmd[1] + " " + cmd[2]);
                Process proc = rt.exec(cmd);
                // any error message?
                grabStream(proc.getErrorStream(), "error");
                // any output?
                grabStream(proc.getInputStream(), "output");
                // any error???
                int exitVal = proc.waitFor();
                if (exitVal != 0)
                    error += "ExitValue: "+exitVal;
            } catch (Exception e){
                e.printStackTrace();
        private void grabStream(InputStream is, String msg){
            if (!(msg.equals("error") || msg.equals("output")))
                return;
            String message = "";
            try{
                InputStreamReader isr = new InputStreamReader(is);
                BufferedReader br = new BufferedReader(isr);
                String line=null;
                while ( (line = br.readLine()) != null)
                    message += line;
            } catch (IOException ioe){
                ioe.printStackTrace();
            if (msg.equals("error"))
                error = message;
            else
                output = message;
    }Then compile the code and move the Console.class file to <web application>/WEB-INF/class/debbie/in/florida/Console.class. The folder should be debbie/in/florida because the package is defined as debbie.in.florida.
    Then your JSP would look like:
        <%//Use the debbie.in.florida namespace because your class is in a package
            debbie.in.florida.Console console = new debbie.in.florida.Console();
        %>
        <script type="text/javascript">
            alert("start");
        </script>
        <%
            console.exec();
            String error = console.getError();
            String output = console.getOutput();
        %>
        <script type="text/javascript">
            alert("end, output = <%=output%> and error = <%=error%>");
        </script>There is a lot wrong with this code, but I won't go and try to fix design problems here, That will be for a later day. But if things are working you should get two popups, one at the start, then your code should execute (or you should get an error message if something is wrong with the code), then a second popup at the end with the response from your application.

Maybe you are looking for

  • How to establish a specific order on an album in itunes?

    The order of the album is supposed to go like this: Live Forever CD1 Live Forever CD2 I Know A Place Punky Reggae Party (Jamaican 12'' Version) Smile Jamaica Who Colt The Game Keep On Moving When I play them on itunes, itunes rearranges them in this

  • How do I import video from my canon vixia hv40 into imovie?

    How do I import video from my canon vixia hv 40 into imovie?

  • TSAFS not communicating with NetBackup

    Hi! I've got a NetWare 6.5 sp7 system, and Symantec NetBackup 6.5.3 software running on top of another system running Red Hat Enterprise Linux AS 4 update 5. I'm attempting to back up GroupWise off the NetWare system to the NetBackup/Red Hat system,

  • Launch iTunes, play specific song in iTunes, and then quit iTunes

    Hi, I'm new to Automator, and would like to figure out how to do the following by clicking on a single icon... 1. launch iTunes 2. play a specific MP3 in iTunes (fifteen minutes of silence sandwiched between two meditation chimes) 2. quit iTunes I op

  • How to install Forms Demos?

    Hi: I've downloaded the Forms Demos for NT but I cannot install it on my computer which I've installed Oracle 8i on it. The Installer said that "Oracle Forms Demos does not support multiple installations, and therefore cannot installed on 'DesDev6i'.