简体   繁体   中英

Open directory from server using Java on local machine

I made an Java application, that on some point opens a local directory or file. The program is located on a server (executed by an other desktop). When an existing folder/file is opened by the app (that is located on the server, and accesed remotely), no screen pops up. If i run the Java program on my desktop, the opening of the of the local folder/file works fine.

I think that the problem is that, when i call the "open folder/file function" i acces the desktop of the server. But the window needs to be openend by the "calling" pc. So i need to specify that the desktop of the calling computer should be used.

How can i accomplish this?

Here is the function that i use to open a folder/file:

try {
    if (Desktop.isDesktopSupported()) Desktop.getDesktop().open(new File(path));
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

the application is remotely accesed something like this: \\\\10.0.0.1\\Java\\App.jar

If you access the Java application like this: \\10.0.0.1\\Java\\App.jar you are still running the application from the local machine. In order for it to be run on the server you would have a Java process running on that server and then on the local machine you would have another Java application that is the client for the server application.

I suppose you are using Windows and your Server is mounted with an SMB share. Try to mount the remote server directory to a local drive letter like R:, this should solve access problems.

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