• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to open text file in Executable Jar.  RSS feed

 
Vicky Thakor
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created JAR file. Which is actually Text editor it works fine.

Now the problem is how to open .txt file by double clicking on Text file that so it'll open in my text editor.

Thanks in Advance.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That has little to do with your program but much more with your operation system. You must register it to associate a file type with your program. It's probably easier to use an installer which handles that for you.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does have a little to do with your application. It must be able to handle command line arguments to pass the text file to open. You can use args[0] from the main method (if args.length > 0) as the file to open.

You then need to set up a file association which calls your application. The command would be That %1 is the first argument to the file association handler. You enclose it in double quotes so that your JVM will receive it as one command if the file name has spaces in it.
 
Vicky Thakor
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You ....i'm done it.....thanks a lot...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!