Skip to content
Advertisement

How to open .txt using windows explorer context menu in java swing?

I am making a text editor for .html, .CSS, .js, .txt etc. First I made my software in java swing and then I changed it to jar file then I changed it to exe file using launch4j and then I made it setup using innosetup but if I install this software and I right click on a file in windows explorer and choose open with and then I select my software and open it, it just open my software not the selected file so how to do it?

Advertisement

Answer

Windows will supply the path to the file as args[0] in your main method.

if(args.length > 0) {
    Path txt = Path.of(args[0]);
    //code to handle
}
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement