how to open any file in Java?

I need the code to run/open/execute any word document/picture/... in windows default application in Java.
This may help : Runtime.getRuntime().exec(myFileLocation);
Please help me.
saffar4everAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ysnkyCommented:
Runtime.getRuntime().exec("cmd /c \""+fileName+"\"");
0
Bart CremersJava ArchitectCommented:
In Java 6 there's support for this.

You can use: java.awt.Desktop.getDesktop().open(new File(myFileLocation));

Prior to Java 6 it's harder to get this right and platform independent.
0
ksivananthCommented:
here is the windows command, which will open the file in appropriate viewer...

rundll32 url.dll,FileProtocolHandler NAME&LOCATION OF THE FILE HERE

you can execute this with Runtime.exec
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
saffar4everAuthor Commented:
thanks all. sorry for being late. pls give me some more time to test. i had pc problems
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.