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

Thread: Execute Linux commands through java program.

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Execute Linux commands through java program.

    HI, i m new to Linux OS. I m trying to create a java program that will execute Linux commands. I do not have any guide. So, it will be a great help if anyone can suggest me any website that has these codes. thanks.


  2. #2
    Junior Member
    Join Date
    May 2011
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Execute Linux commands through java program.

    Sorry for my lack of comprehension, but do you mean that you want to run a java program using linux commands, or run linux commands from a java program? If you wish to execute bash commands from a java program afaik the below should work:

    Runtime.getRuntime().exec("Command");
    Where command is the name of the command you wish to run.

  3. #3
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: Execute Linux commands through java program.

    An oldie but goodie. This article shows you how to implement it properly: When Runtime.exec() won't - JavaWorld

Similar Threads

  1. Replies: 0
    Last Post: November 13th, 2012, 07:02 AM
  2. Replies: 1
    Last Post: June 7th, 2011, 11:53 AM
  3. simple java console program, need help recalling commands
    By zero0000000 in forum Java Theory & Questions
    Replies: 2
    Last Post: October 22nd, 2010, 05:47 AM
  4. Executing Linux Commands with Java GUI
    By linuxrockers in forum AWT / Java Swing
    Replies: 2
    Last Post: February 15th, 2010, 10:57 PM
  5. How to execute a Java program independent of Netbeans.
    By ShaunB in forum Java Theory & Questions
    Replies: 4
    Last Post: January 19th, 2010, 06:23 AM