I have assigned an extension name for my files called *.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. How can I do that?
assuming you work under 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.
EDIT:
OK, step by step:
That's your Java program (export it with Eclipse as a runnable 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 ):
@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. That's it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.