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: Help Needed on Runtime.getRuntime()

  1. #1
    Member
    Join Date
    Mar 2011
    Posts
    114
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Help Needed on Runtime.getRuntime()

    Have written a program to open Excel sheet from java program.

    Below line works fine.

    Process p = Runtime.getRuntime().exec(new String[]{"\"C:\\Program Files (x86)\\Microsoft Office\\Office12\\Excel.EXE\"","C:\\Users\\RASHPA~ 1.ORA\\AppData\\Local\\Temp\\Export_xl420314062726 9379706.xls"});

    But below code gives error i.e. Executable name has embedded quote, split the arguments

    String path = "C:\\Program Files (x86)\\Microsoft Office\\Office12\\Excel.EXE";
    String file = "C:\\Users\\RASHPA~1.ORA\\AppData\\Local\\Temp\\Ex port_xl4203140627269379706.xls";

    Process p = Runtime.getRuntime().exec(new String[]{"\""+path+"\"" + ","+file});


    I am using java 1.6.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Help Needed on Runtime.getRuntime()

    So, if you have code that works fine, what do you need help with?

  3. #3
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Help Needed on Runtime.getRuntime()

    Your first example has a string array with 2 elements and your second example has a string array with only a single element.

Similar Threads

  1. Re: How to Navigate to a URL with Runtime.getRuntime().exec()
    By bharathpangu in forum Java Theory & Questions
    Replies: 1
    Last Post: March 19th, 2012, 12:09 PM
  2. ERROR using Runtime.getRuntime().exec("arp -a");
    By Runomante in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 4th, 2011, 05:09 PM
  3. Runtime.getRuntime().exec(command) - I get nothing
    By andersbk in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 7th, 2010, 08:47 PM
  4. How to Navigate to a URL with Runtime.getRuntime().exec()
    By Flash in forum Java SE API Tutorials
    Replies: 4
    Last Post: October 5th, 2009, 07:18 PM
  5. How to Navigate to a URL with Runtime.getRuntime().exec()
    By Flash in forum Java Code Snippets and Tutorials
    Replies: 4
    Last Post: October 5th, 2009, 07:18 PM

Tags for this Thread