[英]File association using my executable jar file
I have assigned an extension name for my files called *.XSCA. 我为我的文件指定了扩展名* .XSCA。 I would like to read the content of this file when the user click on it using my executable jar file to open it.
当用户使用我的可执行jar文件打开它时,我想读取该文件的内容。 How can I do that?
我怎样才能做到这一点?
assuming you work under windows: 假设您在Windows下工作:
You can write a batch-file with any text-editor. 您可以使用任何文本编辑器编写批处理文件。 Use google to find out how.
使用谷歌找出如何。 It will just be a wrapper for your jar that you can associate in windows with your file-extension-type.
它只是您的jar的包装,您可以在Windows中将其与文件扩展名类型关联。
EDIT: 编辑:
OK, step by step: 好的,一步一步:
That's your Java program (export it with Eclipse as a runnable jar): 那就是您的Java程序(将Eclipse导出为可运行的jar):
public class ExtensionOpener {
public static void main(String[] args) throws InterruptedException {
System.out.println("args:");
for(String arg: args)
System.out.println(arg);
Thread.sleep(3000);
}
}
That's the batch-file (just save it as eg your-starter.bat ): 那是批处理文件(只需将其保存为例如your-starter.bat ):
@echo run bat
java -jar C:\Users\Thomas\Desktop\FileOpener.jar -file -%1
Now click right on your file ( your.fileextension ) and go to properties and associate it with the batch-file. 现在,右键单击文件( your.fileextension ),然后转到属性并将其与批处理文件关联。 That's it.
而已。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.