hard problem. how to track which application a user opens next?

Hello,

When the user runs my program,

then **with his permission**, I want to be able to track

which application the user has opened.

For example, if he opens resume.rtf in MSWord, then I

should be able to record or store the full path of

MSWord and also the document path (c:\my

documents\resume.rtf).

Do you know how to do it?

I would appreciate any help.

thanks,

Anil Philip

[450 byte] By [anilp1a] at [2007-10-2 6:36:20]
# 1
> Do you know how to do it?However it is done, I'm afraid it's not being done by Java.
ChristianMennea at 2007-7-16 13:38:52 > top of Java-index,Java Essentials,Java Programming...
# 2

After thinking it through, I think a better approach is to simply get the document path using

a file chooser. Then one can use the OS's MIME types to open it in the default application

registered for that document type. This can be done in Java by using Runtime.exec(command

line);

Qs. 1) What command will open a document like how (say) Windows opens it when one double-

clicks its icon? Again, we do not know the application name, we simply know the full document

path and are relying on the OS to open it.

2) Is it portable? would it be very different in Macs, Unixes?

It does not seem to be as straightforward as I thought.

-

Anil Philip

for good news go to http://members.tripod.com/~goodnewsforyou/goodnews.html

anilp1a at 2007-7-16 13:38:52 > top of Java-index,Java Essentials,Java Programming...
# 3
A1: Nothing. The ability to click a Windows file and initiate an executable program is provided by and controlled by Windows' file associations.A2. Not portable at all
ChuckBinga at 2007-7-16 13:38:52 > top of Java-index,Java Essentials,Java Programming...
# 4
> A1: Nothing. The ability to click a Windows file and> initiate an executable program is provided by and> controlled by Windows' file associations.Thanks for replying. Are you saying that this cannot be done from the command line?-Anil
anilp1a at 2007-7-16 13:38:52 > top of Java-index,Java Essentials,Java Programming...
# 5
easy solution. http://channel9.msdn.com/ShowPost.aspx?PostID=142155#142155I suppose one must go to the source! in this case Microsoft Developer Forums. BTW. their forums are really cool. I wish Sun could take a leaf from them.
anilp1a at 2007-7-16 13:38:52 > top of Java-index,Java Essentials,Java Programming...
# 6
Well, since you say you have the user's permission, I supposed you could just ask him what he's planning to open next. Or drag out a crystal ball...
Dick_Adamsa at 2007-7-16 13:38:52 > top of Java-index,Java Essentials,Java Programming...
# 7

I'm suprised, the following works. It opens a txt document using Notepad.

String[] s = {"cmd.exe", "/C", "C:\\Documents and Settings\\Chuck\\My Documents\\docName.ext"};

Runtime.getRuntime().exec(s);

ChuckBinga at 2007-7-16 13:38:52 > top of Java-index,Java Essentials,Java Programming...
# 8

> Well, since you say you have the user's permission, I

> supposed you could just ask him what he's

> planning to open next. Or drag out a crystal ball...

Let's put it this way:

There is a list of documents to be automatically opened on the user's machine. eg. resume.doc, memo.html, photo.jpg, acct.xls. He has added them (by browsing in a file chooser) to this list prior to this.

I want to be able to open each document on his machine using the default app.

How can I do it in a cross platform way?

anilp1a at 2007-7-16 13:38:52 > top of Java-index,Java Essentials,Java Programming...
# 9

In this old link

http://www.gamedev.net/community/forums/topic.asp?topic_id=313980

Da Wanderer has posted code (in Visual Basic?) to open a folder. He says it is cross platform. I am stumped by the code for Linux. Does anyone know if it will work for Linux. ie. Can I use the same options to open a document in Linux?

I plan to use Runtime.exec similarly in Java, to open a doc.

........

if (vars.Contains("GNOME_DESKTOP_SESSION_ID"))

{

processes.Add( new ProcessAndArgs("nautilus", "--nodesktop --browser " + path) );

osFound = true;

}

else if (vars.Contains("KDEDIR"))

{

processes.Add( new ProcessAndArgs("kfmclient", "exec " + path) );

osFound = true;

}

anilp1a at 2007-7-16 13:38:52 > top of Java-index,Java Essentials,Java Programming...
# 10
Solution:https://jdic.dev.java.net/Desktop.browse(new java.net.URL(" http://juwo.com"));
anilp1a at 2007-7-16 13:38:52 > top of Java-index,Java Essentials,Java Programming...
# 11
also...Desktop.open(new java.io.File("C:\resume.rtf"));thanks,Anilfor good news go to http://members.tripod.com/~goodnewsforyou/goodnews.html
anilp1a at 2007-7-16 13:38:52 > top of Java-index,Java Essentials,Java Programming...