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 2 of 2

Thread: how to run a command in ubuntu terminal

  1. #1
    Member
    Join Date
    Apr 2013
    Posts
    83
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default how to run a command in ubuntu terminal

    hi im trying to run a few commands in a ubuntu terminal the problem is the last command isint executing
    String product=command1+"\n"+command2+"\n"+command3+"\n"+command4+"\n";
    System.out.println(product);
    Process child3 = Runtime.getRuntime().exec(product);
    if i copy and paste into a terminal it works untill command4 when i have to hit enter to execute command4 which i think is the problem, i tought \n would run the last command as it does the rest but it doesint.

    any ideas thanks.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: how to run a command in ubuntu terminal

    I would use a ProcessBuilder instead, and then redirect the input and output of the Process so you can see any error messages.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 1
    Last Post: June 21st, 2013, 02:23 PM
  2. JAR Run Perfect in My Ubuntu 12.04 but not in Windows or Another OS
    By Malsasa in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 3rd, 2013, 11:06 PM
  3. Replies: 2
    Last Post: July 12th, 2011, 06:24 AM
  4. [SOLVED] can't run javac directly from command prompt
    By epezhman in forum Java IDEs
    Replies: 7
    Last Post: January 12th, 2011, 07:38 PM
  5. Run 2 systems command in applet, how?
    By bulgin in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 8th, 2010, 03:11 PM