0

When I run this in my Windows command prompt it opens the default browser and loads the respective page:

START: http://google.com

I am trying to do the same thing with the Java code below but get an error message.

Runtime.getRuntime().exec(new String[] {"START", "http://google.com"});

This is the error I am getting:

Exception in thread "main" java.io.IOException: Cannot run program "START": CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at Test2.main(Test2.java:78)

I am running Windows Vista.

1
  • try using iexplore/firefox instead of start. I guess "start" would just be a shortcut rather than an executable. Commented Nov 6, 2011 at 4:00

1 Answer 1

3

I believe that START is a command prompt builtin rather than an executable file, so you can't call it from Java. If you want to view a webpage with the system's default browser, use java.awt.Desktop.browse().

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.