Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Backslash issue(Issu with backslashes when setting up run external tool)
Backslash issue [message #1413822] Fri, 29 August 2014 13:58 Go to next message
Clinton Dickerson is currently offline Clinton DickersonFriend
Messages: 2
Registered: August 2014
Junior Member
I am using the Kepler Release of Eclipse with PDT on Windows using XAMPP. I would like to launch the project in Firefox. To do this, I set up a run external tool configuration as:

Location: C:\Program Files (x86)\Mozilla Firefox\firefox.exe
Arguments: 127.0.0.1/workspace2${container_path}/${resource_name}
or 127.0.0.1/workspace2${resource_path}

where 127.0.0.1/workspace2 is my workspace location on Apache

When I run this, Firefox launches but the URL contains backslashes and the @Server not found' message is received. If I change the arguments to 127.0.0.1${resource_path} then resource_path correctly gives forward slashes, but this does not work for me because the path is wrong. It seems that the '/' in the prefix causes the resource file to return with backslashes.

When I look at the documentation for eclipse at http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fconcepts-exttools.htm the example shows that calling ${resource_path} should give forward slashes (as might be expected for a web resource).

I have tried everything that I can think of but I always get the backslashes when I include the workspace path and can't find a way to fix this. Is this a bug in Eclipse? Any ideas or suggestions will be appreciated.
Re: Backslash issue [message #1413954 is a reply to message #1413822] Fri, 29 August 2014 21:21 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 08/29/2014 09:29 AM, Clinton Dickerson wrote:
> I am using the Kepler Release of Eclipse with PDT on Windows using
> XAMPP. I would like to launch the project in Firefox. To do this, I set
> up a run external tool configuration as:
>
> Location: C:\Program Files (x86)\Mozilla Firefox\firefox.exe
> Arguments: 127.0.0.1/workspace2${container_path}/${resource_name}
> or 127.0.0.1/workspace2${resource_path}
>
> where 127.0.0.1/workspace2 is my workspace location on Apache
>
> When I run this, Firefox launches but the URL contains backslashes and
> the @Server not found' message is received. If I change the arguments to
> 127.0.0.1${resource_path} then resource_path correctly gives forward
> slashes, but this does not work for me because the path is wrong. It
> seems that the '/' in the prefix causes the resource file to return with
> backslashes.
>
> When I look at the documentation for eclipse at
> http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fconcepts-exttools.htm
> the example shows that calling ${resource_path} should give forward
> slashes (as might be expected for a web resource).
>
> I have tried everything that I can think of but I always get the
> backslashes when I include the workspace path and can't find a way to
> fix this. Is this a bug in Eclipse? Any ideas or suggestions will be
> appreciated.

You might do better in the Eclipse PDT forum.
Re: Backslash issue [message #1414623 is a reply to message #1413822] Sun, 31 August 2014 23:19 Go to previous messageGo to next message
Toshihiro Izumi is currently offline Toshihiro IzumiFriend
Messages: 360
Registered: July 2009
Location: Japan
Senior Member
Maybe it is a documentation bug.
Path is resolved as OS's path. Since you are on Windows, path separator is translated to the backslash.

http://git.eclipse.org/c/platform/eclipse.platform.debug.git/tree/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/variables/ResourceResolver.java
protected String translateToValue(IResource resource, IDynamicVariable variable) throws CoreException {
...
    } else if (name.endsWith("_path")) { //$NON-NLS-1$
        path = resource.getFullPath();
        if(path != null) {
            return path.toOSString();
        }
...
}
toOSString
/**
 * Returns a string representation of this path which uses the
 * platform-dependent path separator defined by <code>java.io.File</code>.
 * This method is like <code>toString()</code> except that the
 * latter always uses the same separator (<code>/</code>) regardless of platform.
 * <p>
 * This string is suitable for passing to <code>java.io.File(String)</code>.
 * </p>
 *
 * @return a platform-dependent string representation of this path
 */
public String toOSString();


Also, note that Firefox tries to adjust URL if it is malformed.
>If I change the arguments to 127.0.0.1${resource_path} then resource_path correctly gives forward slashes
In this case, Firefox seems to be converting backslash to slash. (but you may encounter same problem if you set "127.0.0.1:80${resource_path}")
>Arguments: 127.0.0.1/workspace2${container_path}/${resource_name}
>or 127.0.0.1/workspace2${resource_path}
In this slash and backslash mixed case, Firefox seems to be converting backslash to "%5c"(URL-form).
(on Windows 8.1 and Firefox 31.0, examined in Command Prompt typing manually)

Try using backslash fully.
External Tools configuration
>>Arguments: 127.0.0.1\workspace2${container_path}\${resource_name}
>>or 127.0.0.1\workspace2${resource_path}

Or try with a batch file.
e.g.
File: starter.cmd
start "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" %1

External Tools configuration
Location: ...\starter.cmd
Arguments: http://127.0.0.1/workspace2${resource_path}

Or ...
Re: Backslash issue [message #1415183 is a reply to message #1414623] Tue, 02 September 2014 09:09 Go to previous message
Clinton Dickerson is currently offline Clinton DickersonFriend
Messages: 2
Registered: August 2014
Junior Member
Thank you for taking the time to provide such a detailed answer, this is much appreciated.

I solved my problem by creating a virtual host (called vhost) and then configured the 'Run As' with
Arguments: vhost${resource_path}

This works with Firefox, IE and Chrome and I now am able to launch the html or php directly to any browser for testing.

Note: if I put 'http://' before vhost then the resource path uses backslashes again and stops working.

Once again, thank you. I have little doubt that your assistance will save others, who also encounter this problem, a lot of time in the future.
Previous Topic:Eclipse Error when I run the app
Next Topic:imports in the outline
Goto Forum:
  


Current Time: Sun Aug 09 04:51:35 GMT 2020

Powered by FUDForum. Page generated in 0.03751 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top