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.
Andrew Thompson
169k42 gold badges224 silver badges441 bronze badges
asked Nov 6, 2011 at 3:55
John R
3,04613 gold badges51 silver badges62 bronze badges
-
try using iexplore/firefox instead of start. I guess "start" would just be a shortcut rather than an executable.aishwarya– aishwarya2011年11月06日 04:00:58 +00:00Commented Nov 6, 2011 at 4:00
1 Answer 1
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().
answered Nov 6, 2011 at 4:01
Matthew Cline
2,3762 gold badges20 silver badges37 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-java