Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 27-06-2008, 03:26 PM   #1 (permalink)
In The Zone
 
jal_desai's Avatar
 
Join Date: May 2006
Posts: 426
Default How to open "My Computer" through a JAVA code??


hi all... i want to open "My Computer" window through a Java Code... i m not able to find the code...

i also wanted to open windows media player through a java code.. and i got success in it.. i used the Process process = Runtime.getRuntimeexec("c:/pro.../../wmplayer.exe"); ... BUT this is possible only if we know the place where the exe is located... and MY COMPUTER is not an exe... i know tht it has a CLSID key which needs to be run in explorer... so can anyone tell me how to run a clsid key from within a JAVA code???

thnks
__________________
TechExplorer.in
jal_desai is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 28-06-2008, 03:10 PM   #2 (permalink)
CAFEBABE
 
chandru.in's Avatar
 
Join Date: Mar 2008
Location: Bangalore
Posts: 474
Default Re: How to open "My Computer" through a JAVA code??

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.
__________________
Chandru

http://tuxychandru.blogspot.com

Last edited by chandru.in; 28-06-2008 at 11:05 PM.
chandru.in is offline  
Old 28-06-2008, 03:22 PM   #3 (permalink)
हॉर्न ओके प्लीज़
 
victor_rambo's Avatar
 
Join Date: Sep 2007
Posts: 1,493
Default Re: How to open "My Computer" through a JAVA code??

http://forum.java.sun.com/thread.jsp...sageID=4158322
__________________
विक्टर रॅंबो - चाणकया प्रभावित व्यक्ति

गीक होना माँगता
victor_rambo is offline  
Old 28-06-2008, 09:11 PM   #4 (permalink)
Legen-wait for it-dary!
 
dheeraj_kumar's Avatar
 
Join Date: Dec 2004
Location: Chennai
Posts: 2,471
Default Re: How to open "My Computer" through a JAVA code??

My computer is not an exe, but Explorer.exe is!!
try:

Code:
Process process = Runtime.getRuntimeexec("C:/Windows/Explorer.exe");
and for opening the users/documents and settings folder for any user, run
Code:
""
yeah put that in the run box and press enter. It might work with the above function, try it.
__________________
If the Start Windows Restart when Windows starts check box is checked Windows Restart will start automatically every time Windows is started. - Actual excerpt from a windows program help file
dheeraj_kumar is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pen drive error messg"Unable to open Script file "F:\MSDLL.dll.vbs" janitha Software Q&A 19 20-04-2007 10:25 PM
"Search" is the first option instead of "Open" Rooney Software Q&A 4 31-01-2007 01:28 PM
Intel debuting long delayed Chip code-named "Montecito" JGuru Technology News 2 20-07-2006 10:39 PM
Microsoft Windows: The End of "My" in "My Computer" Sourabh Software Q&A 14 09-06-2005 11:42 AM

 
Latest Threads
- by Sujeet
- by clmlbx
- by Sujeet
- by icebags

Advertisement




All times are GMT +5.5. The time now is 11:04 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2