Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: response to the execution of an commande by code java

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default response to the execution of an commande by code java

    hello
    in my java program I excecute a command through the code => it works
    but as I stepped into the prog : I found myself with a command that requires an answer after his execution

    then by java program: I do not know how to answer but in the command line I responds with yes and it works
    do you have any idea how to respond through the java code
    I hope you understand the question:
    Here's the code I use for execute command DOS :
    public static String importer_certificat(String alias,String nom_certi,String nom_keystore,String pass_keystore)
        {
            try{
     
                String b = "keytool -import -alias "+alias+" -file "+nom_certi+" -keystore "+nom_keystore +" -storepass "+pass_keystore;
                System.out.println(b);
                Process p = Runtime.getRuntime().exec(b);
                BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
                String inputLine, tous = "";
                while ((inputLine = in.readLine()) != null)
                {
                    tous += "\n"+inputLine;
                    System.out.println(inputLine);
                } 
                return tous;
     
            }catch(Exception e)
            {
                e.printStackTrace();
                return e.getMessage();
            }
        }
    thank you in advance


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: response to the execution of an commande by code java

    The Process class has methods for getting streams for output from the process and for input to the process. See the API doc
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jun 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: response to the execution of an commande by code java

    I don't found

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: response to the execution of an commande by code java

    Here is a link to the API doc:
    Java Platform SE 6
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Java Programming Loop Execution Problem
    By Advent in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 14th, 2012, 04:20 PM
  2. Display Execution Steps - Java Program
    By Max Avion in forum Java Theory & Questions
    Replies: 7
    Last Post: September 14th, 2011, 07:31 PM
  3. java threading execution time question
    By centenial in forum Threads
    Replies: 4
    Last Post: September 8th, 2010, 11:32 PM
  4. Java GUi program Execution
    By Rajan in forum AWT / Java Swing
    Replies: 2
    Last Post: April 19th, 2010, 08:48 PM
  5. java xml-rpc response parsing to xml
    By kievari in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: November 19th, 2009, 02:36 PM