Reputation: 455
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?
Upvotes: 1
Views: 1302
Reputation: 31603
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 e.g. 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.
Upvotes: 1