Automate program execution problem (Runtime.exec("java" + " Hello.java");

Discussion in 'Java' started by seenuvas, Jan 24, 2006.

  1. seenuvas

    seenuvas Guest

    I want to automate the program compilation and execution.

    I used Runtime.exec("javac" +" Hello.java"); for compilation the
    program compiled successfully.
    in the next liine i gave Runtime.exec("java" + "Hello"); This statement
    dosen't performs execution.

    Anybody knows tell me the solution for this problem

    By
    Seenu
     
    seenuvas, Jan 24, 2006
    #1
    1. Advertising

  2. Maybe something simple like Hello's byte code is not within searched
    directories of invoked java executable.

    What's the error? Where is your code?

    Opalinski

    http://www.geocities.com/opalpaweb/
     
    opalinski from opalpaweb, Jan 24, 2006
    #2
    1. Advertising

  3. seenuvas

    seenuvas Guest

    There is no error in the program

    By
    Seenu
     
    seenuvas, Jan 24, 2006
    #3
  4. seenuvas wrote:
    > I want to automate the program compilation and execution.
    >
    > I used Runtime.exec("javac" +" Hello.java"); for compilation the
    > program compiled successfully.
    > in the next liine i gave Runtime.exec("java" + "Hello"); This statement


    You're missing a space. Do you have a program called javaHello?

    > dosen't performs execution.
    >
    > Anybody knows tell me the solution for this problem
    >
    > By
    > Seenu
    >
     
    Jeffrey Schwab, Jan 24, 2006
    #4
  5. seenuvas

    seenuvas Guest

    sorry

    It is Runtime.exec("java" + " Hello");

    There is one space before Hello
     
    seenuvas, Jan 24, 2006
    #5
  6. Want to bet?

    Your refusal to post code is ... weird.

    My specific guess diagnosis is A) you're not directing output from
    subprocess and so you don't see an error B) the error probably talks
    about class not being found.

    ---

    Using java.exe from withing a jvm is questionable.

    ---

    How about wrapping up "java Hello" in a script that runs with an empty
    environment? Then invoke the script with Runtime.exec . If you're
    trying to do something professional handle sub processes streams, man.

    ---

    Opalinski

    http://www.geocities.com/opalpaweb/
     
    opalinski from opalpaweb, Jan 24, 2006
    #6
  7. seenuvas wrote:
    > sorry
    >
    > It is Runtime.exec("java" + " Hello");
    >
    > There is one space before Hello
    >


    maybe the java executable is not found? Try with the full path
    (/opt/jdk/bin/java or C:\whatever)
     
    Francesco Devittori, Jan 24, 2006
    #7
  8. seenuvas

    Roedy Green Guest

    On 24 Jan 2006 04:54:55 -0800, "seenuvas" <>
    wrote, quoted or indirectly quoted someone who said :

    >I used Runtime.exec("javac" +" Hello.java"); for compilation the
    >program compiled successfully.
    >in the next liine i gave Runtime.exec("java" + "Hello"); This statement
    >dosen't performs execution.


    see http://mindprod.com/javacexe.html#MAIN for a more efficient way of
    invoking the Javac compiler.

    you tried to exec "javaHello" which does not exist. You meant
    something like this:

    "java.exe Hello"

    exec wants specific extensions. If you don't have them, you need to
    spawn a command processor that will guess them.

    see http://mindprod.com/jgloss/exec.html
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Jan 24, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MARTIN Herve \(EXT\)
    Replies:
    1
    Views:
    1,515
    Anthony Borla
    Nov 27, 2003
  2. Dave
    Replies:
    2
    Views:
    618
    Tony Morris
    Oct 2, 2004
  3. seenuvas
    Replies:
    0
    Views:
    535
    seenuvas
    Jan 24, 2006
  4. Hal Vaughan
    Replies:
    11
    Views:
    1,198
    Gordon Beaton
    May 22, 2006
  5. Replies:
    12
    Views:
    5,200
    Roedy Green
    Apr 19, 2009
Loading...

Share This Page