The following fix my problem.
public EHWInit()
{
String resetRootPath = "";
try{
resetRootPath = this.getClass().getResource("/").getPath();
boolean isWinOS = System.getProperty("os.name").startsWith("Windows");
if( isWinOS )
{resetRootPath = resetRootPath.substring(1, resetRootPath.lastIndexOf("chucec"));}
else
{resetRootPath = resetRootPath.substring(0, resetRootPath.lastIndexOf("chucec"));}
resetRootPath = resetRootPath.replace("%20", " ");
System.out.println("EHWInit#75:resetRootPath=" + resetRootPath);
When you try to get getRealPath by this.getClass().getResource("/").getPath() when OS is Windows, then you may get a string like following:
EHWInit#73:getPath=/C:/Program%20Files%20(x86)/Apache%20Software%20Foundation/Tomcat%208.5/webapps/chucec/WEB-INF/classes/
Therefor, you need do some extra works on the returning string.Furthermore, if you want to get getRealPath by request. You can replace the code like follows:
public void resetSystemPath(HttpServletRequest paramHttpServletRequest)
{
//String str = paramHttpServletRequest.getRealPath("/");
HttpSession session = paramHttpServletRequest.getSession(true);
String str = session.getServletContext().getRealPath("/");
System.out.println("getRealPath:"+str);