Space in Path on Windows

Sometimes you may experience problems when using the Profiler installed in path which contains spaces. Whereas for using Profile Project action everything works fine, for Attach Profiler where you have to start profiled application with special "-agentpath" argument problems may occur. For default NetBeans installation directory on Windows the argument typically looks like this:

-agentpath:"C:\\​Program Files\\​netbeans-5.0\\​profiler1\\​lib\\​deployed\\​jdk15\\​windows\\​profilerinterface.dll=\\​"C:\\​Program Files\\​netbeans-5.0\\​profiler1\\​lib\\​"",5140

However, some applications/servers parse this argument from command line incorrectly and pass it to the Profiler agent in bad format. Typically you will find something like "Profiler Agent: Options: >\\C:\\Program<" in profiled application's console in that case and profiled application fails to start.

There is a simple workaround to fix this problem: 8.3 DOS path format should be used, it doesn't contain spaces in path. Then all quotes and escape backslashes need to be removed. Profiler argument in this format looks like this:

-agentpath:C:\\​PROGRA~1\\​netbeans-5.0\\​profiler1\\​lib\\​deployed\\​jdk15\\​windows\\​profilerinterface.dll=C:\\​PROGRA~1\\​netbeans-5.0\\​profiler1\\​lib,5140

Whereas for "C:\\Program Files" the short form should always be "C:\\PROGRA~1", for other directories you should ask the OS for correct path. You can do it in Command Prompt (cmd.exe) using dir /X command. In general getting 8.3 paths is not as trivial as it may seems, the best way is to call GetShortPathName function of Windows API.

And - of course - another simple workaround is to move the NetBeans directory somewhere on path without spaces.

Comments:

Use 'command prompt' to navigate to the directory in question.
Then call command.com.
This switches to a new shell and the path will display in 8.3 format.
Then, do a dir to get the name of the .dll in 8.3
Use all that to put together the -agentpath

Posted by phacdelm on April 22, 2008 at 12:06 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

A blog by NetBeans Profiler & VisualVM developers.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today