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: need help connecting to linux server and execute linux commands using local java proj

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default need help connecting to linux server and execute linux commands using local java proj

    am practically new to this forum and my apologies first of all coz not sure whether this is the section for this thread...

    my req is to create a stand alone java class tht will connect to external linux servers and execute linux commands there...

    this is totally new field for me and have no idea on the same.
    jus expecting experts to gimme few paths from where i can start my research on...


  2. #2
    Junior Member
    Join Date
    Jun 2011
    Location
    Salt Lake City, Utah
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: need help connecting to linux server and execute linux commands using local java

    Are you looking to run linux commands from the Java application? If so one way I used that works well is:

    String[] commandShutdown = {
      "gnome-terminal",
      "-e", 
      "sudo /sbin/shutdown -h now"
    };
     
    try {
      Runtime.getRuntime().exec(commandShutdown);
    } catch {IOExecption e) {
     e.printStackTrace();
    }

    what ever commands you're trying to use you would use the Runtime.

Similar Threads

  1. Replies: 3
    Last Post: March 8th, 2011, 07:44 AM
  2. How to set java compiler compliance with command under Linux
    By Eric97 in forum Java Theory & Questions
    Replies: 2
    Last Post: November 9th, 2010, 09:25 AM
  3. miniBuilder on Linux- java errors
    By nwtjv in forum Exceptions
    Replies: 0
    Last Post: March 25th, 2010, 06:54 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. getting files in the linux server
    By Truffy in forum Java Networking
    Replies: 36
    Last Post: June 22nd, 2009, 06:32 PM