Results 1 to 5 of 5
  1. #1
    jazz2k8's Avatar
    jazz2k8 is offline Senior Member
    Join Date
    Apr 2008
    Posts
    150
    Rep Power
    7

    Thumbs up [SOLVED] How to give the path when there exists spaces

    Hi Folks,

    How to give the path when there exists spaces in that.

    ex:

    import java.io.*;
    class batrun{
    public static void main(String arg[]){
    try{
    String command = "cmd /C start C:/myapp.exe ";

    Runtime rt = Runtime.getRuntime();
    Process pr = rt.exec(command);

    }catch (IOException e) {
    e.printStackTrace();
    }
    }
    }
    it is running perfect..

    but when i give

    import java.io.*;
    class batrun{
    public static void main(String arg[]){
    try{
    //String command = "cmd /C start C:/myapp.exe ";
    String command = "cmd /C start C:/Program Files/application/myapp.exe";
    Runtime rt = Runtime.getRuntime();
    Process pr = rt.exec(command);

    }catch (IOException e) {
    e.printStackTrace();
    }
    }
    }
    it is not recognizing the path.

  2. #2
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    put in quotes and esc it.
    Java Code:
    String command = "cmd /C start \"C:/Program Files/application/myapp.exe\"";
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

  3. #3
    jazz2k8's Avatar
    jazz2k8 is offline Senior Member
    Join Date
    Apr 2008
    Posts
    150
    Rep Power
    7

    Default

    When i run with the above given code it opens another command prompt window with the given path ..please find the attachment.

    can any body help me in this?
    Attached Thumbnails Attached Thumbnails [SOLVED] How to give the path when there exists spaces-newwin.jpg  

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    800
    Rep Power
    6

    Default

    Hi,
    Could you remove 'start' and try once?
    Ramya:cool:

  5. #5
    jazz2k8's Avatar
    jazz2k8 is offline Senior Member
    Join Date
    Apr 2008
    Posts
    150
    Rep Power
    7

Similar Threads

  1. how can i give a file path to java stream ?
    By sheckoo in forum New To Java
    Replies: 2
    Last Post: 11-05-2008, 08:42 AM
  2. How to check whether file is exists or not
    By Java Tip in forum java.io
    Replies: 0
    Last Post: 04-05-2008, 10:13 AM
  3. Check if a web page exists or not
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-02-2008, 07:24 PM
  4. Load URL that contains spaces?
    By barkster in forum Java Applets
    Replies: 0
    Last Post: 01-30-2008, 09:40 PM
  5. Replies: 1
    Last Post: 01-10-2008, 01:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •