Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 419808 - [Workbench] Unable to launch internal browser using IWorkbenchBrowserSupport.createBrowser due to Runtime.exec() exception
Summary: [Workbench] Unable to launch internal browser using IWorkbenchBrowserSupport....
Status: CLOSED DUPLICATE of bug 405942
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact: Paul Webster CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-18 03:23 EDT by Nitish Thakur CLA
Modified: 2013-10-25 08:41 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nitish Thakur CLA 2013-10-18 03:23:50 EDT
We are using the API PlatformUI.getWorkbench().getBrowserSupport().createBrowser(IWorkbenchBrowserSupport.AS_EDITOR, . . ..) to launch internal browser as an Editor.
The default browser is IE8 and we want to change it to Mozilla. But there is no way to change the default internal browser.

We set the Web Browser preference to use external Mozilla browser but its unable to launch because of following exception:
!MESSAGE Launching C:\Program Files (x86)\Mozilla Firefox\firefox.exe has failed.
!STACK 0
java.io.IOException: Cannot run program "C:\Program": CreateProcess error=2, The system cannot find the file specified.
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
	at java.lang.Runtime.exec(Runtime.java:617)
	at java.lang.Runtime.exec(Runtime.java:450)
	at java.lang.Runtime.exec(Runtime.java:347)
	at org.eclipse.ui.internal.browser.browsers.MozillaBrowser$BrowserThread.openBrowser(MozillaBrowser.java:94)
	at org.eclipse.ui.internal.browser.browsers.MozillaBrowser$BrowserThread.run(MozillaBrowser.java:165)
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:376)
	at java.lang.ProcessImpl.start(ProcessImpl.java:136)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)

The explaination to above exception is - Runtime.exec() implementation in recent jdk versions throw java.lang.IllegalArgumentException when you try to spawn a process that has got a space in its fully qualified path name on windows platform 

The current workaround is to use the following vmargs in eclipse.ini:
-Djdk.lang.Process.allowAmbigousCommands=true

Using this vmargs we are able to launch Mozilla externally but when tried with IE launch still fails.

Issues being reported:
1. PlatformUI.getWorkbench().getBrowserSupport().createBrowser should have an option to launch other browsers apart from system default as an editor.
2. The Runtime.exec() exception while launching external browser should be resolved.
Comment 1 Paul Webster CLA 2013-10-18 09:12:06 EDT
What version of java are you using?

PW
Comment 2 Paul Webster CLA 2013-10-18 09:12:24 EDT
Wojtek, could you please try and reproduce on windows7?

PW
Comment 3 Wojciech Sudol CLA 2013-10-18 10:10:07 EDT
It works fine in my environment:
- Windows 7
- Firefox installed in C:\Program Files (x86)\Mozilla Firefox\firefox.exe
- JRE 1.7.0_11
tested on Eclipse 4.2.1 and 4.4
Comment 4 Nitish Thakur CLA 2013-10-18 10:19:43 EDT
Java version:
java version "1.7.0"
Java(TM) SE Runtime Environment (build pwi3270sr5-20130619_01(SR5))
IBM J9 VM (build 2.6, JRE 1.7.0 Windows 7 x86-32 20130617_152572 (JIT enabled, A
OT enabled)
J9VM - R26_Java726_SR5_20130617_1436_B152572
JIT  - r11.b04_20130528_38954ifx1
GC   - R26_Java726_SR5_20130617_1436_B152572
J9CL - 20130617_152572)
JCL - 20130616_01 based on Oracle 7u25-b12


Environment:
Windows server 2008 R2
64 Bit OS
Comment 5 Wojciech Sudol CLA 2013-10-18 10:43:29 EDT
I tested it also on Java 1.6 32bit with eclipse 32bit. Still works fine.
Comment 6 Paul Webster CLA 2013-10-24 16:32:02 EDT
(In reply to Wojciech Sudol from comment #3)
> - JRE 1.7.0_11


Are you using a 64-bit JRE?

PW
Comment 7 Wojciech Sudol CLA 2013-10-25 05:39:44 EDT
I updated my JRE and now I am able to reproduce the bug. The problem is a result of changes in JDK 7u21 and is described here: http://www.oracle.com/technetwork/java/javase/7u21-relnotes-1932873.html#jruntime.
The problem seems to be really serious and affects every place where Runtime.exec() is used.
Comment 8 Paul Webster CLA 2013-10-25 08:41:59 EDT

*** This bug has been marked as a duplicate of bug 405942 ***