将jar设置为文件的默认程序 [英] set jar as default program for a file

查看:234
本文介绍了将jar设置为文件的默认程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用我自己的jar文件打开一个特定的文件格式。这意味着:我想双击test.bo2文件,这应该打开我的java程序,并发送该文件的路径(也许作为命令行参数)。是这样的东西吗?

I want to open a specific file-format with my own jar file. That means: I want to double-click the test.bo2 file and that should open my java program and send the path of that file (maybe as command-line argument). Is something like that possible?

目前我猜一个.jar文件不是一个程序,所以有一个解决方法从.exe运行一个java文件或这样的东西?任何建议?

At the moment I guess a .jar file is not a program, so is there a workaround to run a java file from a .exe or something like that? Any suggestions?

再进一步,我如何在第一次启动时自动设置此项?

And, to go a step further, how can I automatically set this on the first startup?

推荐答案

正如你在谈论.exe我假设你使用的是Windows。

As you are talking about ".exe" I assume you are using Windows.

您可以使用 ftype 注册新的扩展程序和相应的程序assoc

打开命令行窗口,然后键入以下内容:

Open a commandline window, and type the following:


  1. 注册新扩展程序:

  1. Register the new extension:

assoc .bo2 = GenaeDocument

将新类型与程序相关联:

Associate the new type with a program:

ftype GenaeDocument = javaw.exe -jar \path\to\your\program.jar%1

你显然需要调整你的jar文件的路径。这也假设 javaw.exe 可以在路径中找到。如果不是这样,只需使用完整路径 javaw.exe

You will obviously need to adjust the path to your jar file. This also assumes javaw.exe can be found on the path. If that is not the case, just use the full path to javaw.exe.

.bo2 文件应该启动您的应用程序。我假设你正在使用一个Swing(GUI)应用程序,因此ftype使用 javaw.exe 。如果你的应用程序是一个控制台程序,你应该使用 java.exe

After this, a doubleclick on a .bo2 file should start your application. I assumed you are using a Swing (GUI) application, therefor the ftype is using javaw.exe. If your application is a console program instead, you should use java.exe

通过ConrolPanel / Explorer,但我发现使用命令行更快更容易)

(Note this can be done somehow through the ConrolPanel/Explorer as well, but I find it quicker and easier using the commandline)

这篇关于将jar设置为文件的默认程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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