How to Open file by double clicking on it in our .jar file?
This article helps desktop application developer in java. If you have application which saves its own file format. You always wanted to handle that file in your application. We use windows registry to handle the request. Let me write the topic that users searches over internet so it'll help them too.
- How to open my file format in .jar file?
- How to open file by double clicking on it in our .jar file?
- Open file in .jar file?
- Setup our file format extension with our .jar file?
So first of all you have decided your file format like we are using (.beta). This is my Personal editor application file format.Now setting up that format. We are working in Windows machine.
Step 1: Open Run. Start>Run or Window key + R
Step 2: Type “regedit” (without double quote).
Create New Key under HKEY_CLASSES_ROOT.
Name it with your file format extension. (.beta)
Now Double click on (Default) and change the value to Your_File_FormatFile
Now Create another key under the same path HKEY_CLASSES_ROOT. And name it same as given above Your_File_FormatFile and create other key in hierarchy shown in below image.
To setup your file Icon click on DefaultIcon and setup the icon path check the below image.
Now click on the command and setup your file path (.jar file). Check below image.
In image you can see the command as : “javaw.exe” “-jar” “Your .jar file location” “%1”
Don’t change anything else %1 pass your file path to your main method. In public static void main(String args[]) you'll have your file name in args[0].
Now you have to handle your file in main method. In main method do some work that handle your file like open it in text area or something as like you open it from the file open.
0 comments :