How to mount a network drive in Mac OS X in Java?

I am writing a program on JBuider 2005 on a Windows XP platform for Mac OS X. The program should run on Mac OS X, and the program will switch (direct) to share folders on another computer (Windows XP) on the network. It is necessary that we then run nprogramme on Mac OS X, this program will automatically mount these shared folders under Mac OS X. Then the program will go to the files in the shared folder, and the path in the program will be "/ Volumes / Share folder / File". How can i do this? Help if anyone knows how to do this.

+4
source share
2 answers

If this is what you need to connect, then the code is as follows:

Process p1 = Runtime.getRuntime().exec("/bin/mkdir /Volumes/<mountName>"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec(new String[] {"/sbin/mount_afp","-i","afp://<user>:<passwd>@url.of.serv.er/mountPath/","/Volumes/<mountName>/"}); p2.waitFor(); 

If it is smb-mount, then the code is as follows:

  Process p3 = Runtime.getRuntime().exec("/bin/mkdir /Volumes/<mountName>"); p3.waitFor(); Process p4 = Runtime.getRuntime().exec(new String[] {"/sbin/mount","-t","smbfs","//<user>:<passwd>@url.of.serv.er/mountPath/","/Volumes/<mountName>/"}); p4.waitFor(); 
+3
source

Perhaps start a little AppleScript where the Finder mounts the shared folder. This article describes the launch of AppleScript from a Java program.

Or run the shell script:

 mount -t smbfs // user@server /share folder 
+1
source

Source: https://habr.com/ru/post/1302099/


All Articles