how to launch a file (.txt file) upon clicking a button

hi,can anyone tell me how to make a file open ( local file) upon clicking a button .i mean within actionperformed() of that button , i want to write a code that launches a a text file.please tell me how to do this ,Thanks,vishal j
[272 byte] By [vishal_vja] at [2007-11-26 14:55:58]
# 1
Define 'launch.'
itchyscratchya at 2007-7-8 8:44:31 > top of Java-index,Desktop,Core GUI APIs...
# 2
By saying 'launch' , i mean the code should look for that file in the specified file path & should open up on your desktop.
vishal_vja at 2007-7-8 8:44:31 > top of Java-index,Desktop,Core GUI APIs...
# 3
So in a native app then?There was a post a day or two in here which gave a code example. I just searched for it, but the search engine for these forums being the pile of incompetent dung that it is, I couldn't find it. It's there somewhere though :o)
itchyscratchya at 2007-7-8 8:44:31 > top of Java-index,Desktop,Core GUI APIs...
# 4

I assume it is Windows. exec this:

String theFileToStart = "my.txt";

String toexec [] = new String[] { "cmd" , "/c" , "start" , theFileToStart };

BIJ001a at 2007-7-8 8:44:31 > top of Java-index,Desktop,Core GUI APIs...
# 5

well i tried this already & its not working.

I tried doing something like this

String filename = "C:\\Documents and Settings\\Administrator\\Desktop\\link.txt";

Runtime.getRuntime().exec(new String []{ "cmd", "/C" , "start" , filename});

after running this code , its bringing up a command prompt dialog on the desktop ,but actually i want the file to open up on the desktop.

Any help is appreciated

Thanks,

vishal

vishal_vja at 2007-7-8 8:44:31 > top of Java-index,Desktop,Core GUI APIs...
# 6
private static final String WIN_PATH = "rundll32";private static final String WIN_FLAG = "url.dll,FileProtocolHandler";..... File file = new File("file.txt"); Runtime.getRuntime().exec(WIN_PATH + " " + WIN_FLAG + " " + "\""+file.getAbsolutePath()+"\"");
Rodney_McKaya at 2007-7-8 8:44:31 > top of Java-index,Desktop,Core GUI APIs...
# 7
Use java 1.6.Desktop.open();
es5f2000a at 2007-7-8 8:44:31 > top of Java-index,Desktop,Core GUI APIs...
# 8
Simple example here: http://forum.java.sun.com/thread.jspa?forumID=57&threadID=5123633
camickra at 2007-7-8 8:44:31 > top of Java-index,Desktop,Core GUI APIs...