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: Program that Opens/Executes a File on Windows

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Program that Opens/Executes a File on Windows

    I made a program that could open a file on a mac and it worked fine. For some reason when I try it on Windows with this code I receive an error message.
    try{
    	Runtime.getRuntime().exec(new String[] {"rundll32 url.dll,FileProtocolHandler",
    				"C:\\Documents and Settings\\Folder\\Filename"});
    		} catch(IOException e) {
    			e.printStackTrace();
    		}

    The error message is:

    java.io.IOException: Cannot run program "rundll32 url.dll,FileProtocolHandler": CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(ProcessBuilder.java :459)
    at java.lang.Runtime.exec(Runtime.java:593)
    at java.lang.Runtime.exec(Runtime.java:466)
    at fileFinderP.MostRecentFile.main(MostRecentFile.jav a:39)
    Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
    at java.lang.ProcessImpl.start(ProcessImpl.java:30)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java :452)
    ... 3 more

    I checked and made sure the file path was right, and it was. Then I rechecked the way I specified "rundll32...." and that was correct as well. I also added with no avail the try/catch statements to see if that may help, as it was necessary for my program to work on my mac.

    My entire program is attached in case that may help.
    Attached Files Attached Files


  2. #2
    Junior Member
    Join Date
    Jul 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Program that Opens/Executes a File on Windows

    Problem solved. I just had to change my array around to:

    {"rundll32", "url.dll,FileProtocolHandler", "C:\\Documents and Settings\\Folder\\Filename"}

Similar Threads

  1. Run a jar file inside a batch file with Windows 7 Task schduler
    By kingnachi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 15th, 2012, 09:20 AM
  2. looking for a program to manage windows power plans
    By lordrt in forum Java Theory & Questions
    Replies: 0
    Last Post: May 13th, 2012, 03:26 AM
  3. Windows 7 - jar file not opening a window
    By Yaten13 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 10th, 2011, 05:53 PM
  4. Ant Executes and Stops After a Certain Task
    By DanielPros in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 9th, 2011, 10:46 AM
  5. My Jar File Crashing Windows 7
    By PrinceSendai in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 19th, 2011, 01:49 PM