How do I add new .java file to context new menu?


  1. Posts : 5
    Window 10 Pro
       #1

    How do I add new .java file to context new menu?


    Hello, I want create a new blank java source code file from the context menu when I right click in
    a folder and select new.

    I have tried adding a registry edit with the following code:

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\.java\ShellNew]
    "NullFile"=""

    This does not work even after a restart.
      My Computer


  2. Posts : 9,790
    Mac OS Catalina
       #2

    First question would be why. The second would be what are you trying to accomplish.
      My Computer


  3. Posts : 18
    Win 10 Pro
       #3

    RedBushTea said:
    Hello, I want create a new blank java source code file from the context menu when I right click in
    a folder and select new.

    I have tried adding a registry edit with the following code:

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\.java\ShellNew]
    "NullFile"=""

    This does not work even after a restart.
    Did you set a value?
      My Computer


  4. Posts : 5
    Window 10 Pro
    Thread Starter
       #4

    I want to do this so that I can create a new java source code file from the context menu, then I will open the file in
    a text editor and write the java source code as part of a set of java programming lessons.

    I can create a new text file from the context menu and then rename the file extension to .java or other work around
    methods but I think having a menu item in the context menu will be better.
      My Computer


  5. Posts : 5
    Window 10 Pro
    Thread Starter
       #5

    docpipo said:
    Did you set a value?
    I did not set a value as I copied the code from another forum, and as far as I know this code will allow a new blank file
    to be created.
      My Computer


  6. Posts : 18
    Win 10 Pro
       #6

    RedBushTea said:
    I did not set a value as I copied the code from another forum, and as far as I know this code will allow a new blank file
    to be created.
    I'd say try setting it to 1, and see what happens. I tried it but I didn't look up a code yet and I'm no expert, just a suggestion
      My Computer


  7. Posts : 5
    Window 10 Pro
    Thread Starter
       #7

    docpipo said:
    I'd say try setting it to 1, and see what happens. I tried it but I didn't look up a code yet and I'm no expert, just a suggestion
    Thanks, I changed the value to 1 as you suggested but it still does not work.
      My Computer


  8. Posts : 5
    Window 10 Pro
    Thread Starter
       #8

    After some research and trial and error I have got it working, I found useful information in various web pages
    including:
    windows - How can I add an item to the context menu? - Super User
    and
    Adding Items to the "New" Context Menu (Tips.Net)

    So after making changes to the registry and exiting regedit, I had to close all Explorer windows and then restart Explorer for the changes to take effect.

    Below is the code I have exported from regedit, I don't know if all the changes are needed but it works

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\.java]
    "PerceivedType"="text"
    @="JavaSourceFile.Document"

    [HKEY_CLASSES_ROOT\.java\PersistentHandler]
    @="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

    [HKEY_CLASSES_ROOT\.java\ShellNew]
    "NullFile"=""
    "FileName"="C:\\Windows\\ShellNew\\Template.java"
    "~NullFile"=""

    [HKEY_CLASSES_ROOT\JavaSourceFile.Document]
    @="JAVA Source File"

    [HKEY_CLASSES_ROOT\JavaSourceFile.Document\DefaultIcon]
    @="C:\\Program Files (x86)\\Notepad++\\notepad++.exe,0"
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 17:11.
Find Us




Windows 10 Forums