views:

223

answers:

2

I am writing a programme on JBuider 2005 on Windows XP platform for Mac OS X. Programme must launch on Mac OS X and programme turnes(directs) to share folders on other computer(Windows XP) in network. It is necessary that then we launch nprogramme on Mac OS X this programme automatically mount these share folders under Mac OS X. Then programme turnes to files on share folder and path in program will be "/Volumes/Share folder/File". How can i make it? Help, if anyone knows how to do it.

A: 

Perhaps run a bit of AppleScript which has Finder mount the shared folder. This article describes running AppleScript from a Java program.

Or run a shell script:

mount -t smbfs //user@server/share folder
unhillbilly
A: 

If it is a afp-volume that you have to mount, the code looks like this:

   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 a smb-mount, then the code looks like this:

    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();
Erik