I have a file "test.File". I want to use java to run that file with a program eg. Paint.NET. How can I do that?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I have a file "test.File". I want to use java to run that file with a program eg. Paint.NET. How can I do that?
What does "run that file" mean?
Are you asking how to ask the OS to start a program when it is given a file to be opened?
See the Desktop class.
Or if you have the full commandline to execute, see the Runtime class.
If you don't understand my answer, don't ignore it, ask a question.
I'm how to programatically execute test.File with Paint.NET (equallent of right clicking test.File, clicking "open with", then selecting Paint.NET)
If you want to specify the command to use to open the file,
build a commandline and use the Runtime exec() method to execute it.
If you don't understand my answer, don't ignore it, ask a question.
and what command should i pass in the Runtime.exec() method??
The command that you want to execute.
If you don't know the command, you should use the Desktop class.
If you don't understand my answer, don't ignore it, ask a question.