简体   繁体   中英

Java can't find Mapped Network Drive under Windows 2008 R2

We try to access file under some folder, in WinXP, that folder can be local disk or mapped network drive. But when we change our program to run on Windows 2008 R2, it can access local disk, but no mapped network drive. The mapped network drive had checked for login with proper user.

We try in explorer, the mapped drive can Read/Write as we wished, but Java just show "Folder doesn't exist"

Here is our code, any suggestion will be appreciated.

    #import java.io.File;
    ...
    File folder = new File(folderPath);
    if(!folder.exists()){
        // do something
        log.debug("Folder doesn't exist");
    } else {
        // do something else
    }
    ...

Mapped drive may be not found for current user. For example, if you start some jar executable as administrator it may not find network drive which was mapped under user credentials. In a word, it can be a user identification problem.

I've had this problem with Windows Server 2008 64bit and had no luck using a path with network letter (eg X:\\EXAMPLE\\PATH ). Using full network paths ( \\\\SERVER\\EXAMPLE\\PATH ) was ok. The path should be accesible to the user who will run the program.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM