How to save a file with .java extension?



  • Hello guys!

    I open Notepad++, choose Java syntax in options, write code, then I want to save it as .java file. I name the file, e.g. “Main”, then choose file type for “Java source file (*.java)” and after clicking “Save” the file is created but its type is called “File”. I know that I can manually add “.java” in the end of file name but I’d like to figure out why I am unable to save it by choosing one of listed extensions. I saw on one of the Java course videos that after clicking “Save as…” the file extension is automatically set to “.java”. I have newest version of Notepad++(7.8.4) and JDK(13.0.2).

    I will appreciate any help and answer all questions if I described something imprecisely.



  • If you want it to automatically append extensions, then you have to go to Settings > Preferences > Default Directory and turn off Use new style dialog. More on this setting in the official docs.

    There are dangers of using the old-style, not the least of which if you select “C++ source file”, it will use the extension .h rather than .cpp, because .h happens to be first in that particular list of extensions for the file type.



  • @PeterJones, thank you so much for your reply. It solved my problem. Much obliged.


Log in to reply