Use a Java application as the Default Program for a particular file type?

前端 未结 2 1218
南方客
南方客 2020-12-09 20:30

I have created a text editor using Java, and have it packed in a jar file using Netbeans. Now I created a text file, with an extension of \".text\". I\'m on Windows 7, so us

2条回答
  •  遥遥无期
    2020-12-09 20:55

    The problem is that a JAR file is selected as the "default application". However, JAR files are normally not executable. That is, a JAR file is not a valid Windows application. It doesn't matter if the JAR extension itself has a default application associated with it, because the "Open verb" is not used recursively in other "Open verb" definitions.

    Instead,

    1. Create a batch (".BAT") file (or small EXE wrapper) that calls java (or javaw, as appropriate) and use that executable wrapper as the "Open with" program. (This will have an annoying intermediate console window if using a batch file.) Or,
    2. Modify the registry so that the "Open verb" for the extension launches the JAR through java (or javaw).

    In the end, either form should look similar to: javaw -jar TheJarFile.jar "%1%". (Note that javaw is an executable, while TheJarFile.jar is not an executable.)

    See java - the Java application launcher for how to use java/javaw.

提交回复
热议问题