I don't think it is possible to open "My Computer" itself as it does not have a path in Windows Operating System. However, if you want to open a specific directory using the Operating System's default file manager, you can try the following code. It works in a completely platform independent manner, unlike the Runtime.exec() method invocation.
Code:
package main;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import javax.swing.filechooser.FileSystemView;
public class Main {
public static void main(String[] args) throws IOException {
Desktop desktop = Desktop.getDesktop();
File dirToOpen = new File("C:\\some_directory");
desktop.open(dirToOpen);
}
}
If you want to open the default directory for current user ("My Documents" on Windows and user's home directory on Linux and UNIX), you can use the following code to get a File object for the default directory.
Code:
File defaultDirectory = FileSystemView.getFileSystemView().getDefaultDirectory();
Hope it helped you a bit.
Note: The Desktop class used above is available from Java 6.