How to launch the default (native) application for a given file from Java?

前端 未结 3 1982
春和景丽
春和景丽 2020-12-03 08:53

I am displaying a list of files; i.e. xls, doc, pdf, odt etc., in my Java application (Eclipse RCP). When the user clicks on the file, I want to launch the appropriate (acc

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 09:42

    Sounds like you're after the Java Activation Framework ("JAF"). This API lets you determine what files are and what actions you can do on them. Or alternatively the Java Desktop Integration Component ("JDIC"). JDIC allows you to create and no doubt query file associations.

    Both projects seem to be in a semi-abandoned state howeer (sigh). But that's par for the course for Sun these days. Only other thing I know of is some Windows specific third party library that's based on JNI called Winpack. It does a bunch of other things too.

    You can get the associated icon using the FileSystemView class (Java 1.4+).

提交回复
热议问题