使用Java应用程序作为特定文件类型的默认程序? [英] Use a Java application as the Default Program for a particular file type?

查看:166
本文介绍了使用Java应用程序作为特定文件类型的默认程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Java创建了一个文本编辑器,并使用Netbeans将其打包在一个jar文件中。
现在我创建了一个文本文件,扩展名为.text。
我在Windows 7上,所以使用它的属性窗口我将默认的打开程序更改为我的文本编辑器的jar文件。

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 using it's property window I changed the default opening program to my text editor's jar file.

现在当我双击带有.text扩展名的文件,windows显示一个对话框,说{file name}不是一个有效的win32应用程序。

Now when I double click the file with ".text" extension, windows shows a dialogbox saying "{file name} is not a valid win32 application".

请帮帮我..

谢谢。

推荐答案

问题是选择了JAR文件作为默认应用程序。但是,JAR文件通常不是可执行文件。 也就是说,JAR文件不是有效的Windows应用程序。 JAR扩展本身是否有与之关联的默认应用程序并不重要,因为Open verb not 在其他开放动词定义中递归使用。

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.

相反,


  1. 创建一个批处理(.BAT)文件(或小型EXE包装器),调用 java (或 javaw ,视情况使用)并将该可执行包装器用作打开方式程序。 (如果使用批处理文件,这将有一个烦人的中间控制台窗口。)

  2. 修改注册表,以便扩展程序的打开动词启动JAR 通过 java (或 javaw )。

  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).

最后,任何一种形式应该类似于: javaw -jar TheJarFile.jar%1%。 (注意 javaw 是可执行文件,而 TheJarFile.jar 不是可执行文件。 )

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.)

参见 java - Java应用程序启动器,了解如何使用java / javaw。

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

这篇关于使用Java应用程序作为特定文件类型的默认程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆