Configure Notepad++ to Run C, C++ and Java Programs

In this tutorial I will tell you about how to configure notepad++ to run C, C++, Java, Python, JavaScript, etc. programs.

Notepad++ is a popular and free source code editor which is widely used by programmers. Even I use it very frequently. Today while editing a source code on notepad++ I thought that it will be great if there is any way to run the source code on it. Luckily I found a way that I am sharing below. I have mentioned steps only for C, C++ and Java. But the same method can be used to run programs of any other language.

Configure Notepad++ to Run C, C++ and Java Programs

 

Configure Notepad++ to Run C, C++ and Java Programs

1. First of all download the notepad++ from below link.

https://notepad-plus-plus.org/download/

2. Now install and open notepad++.

3. We require NppExec plugin that will help us to run programs. You can skip 3rd and 4th steps if the NppExec plugin is already present in notepad++. Go to Plugins > Plugin Manager > Show Plugin Manager.

Notepad++ 1

4. Make sure you have internet connection because we are going to download plugin. In the new window you will get a list of all available plugins. Scroll down and select NppExec plugin from the list and install it.

Notepad++ 2

5. Go to Plugins > NppExec > Execute. Now we have to create a script. In the new window enter following commands and then save it with any name.

 

For C and C++

npp_save
cd $(CURRENT_DIRECTORY)
C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe “$(FILE_NAME)”
cmd /c “$(CURRENT_DIRECTORY)\a.exe”

 

For Java

npp_save
cd $(CURRENT_DIRECTORY)
C:\Program Files\Java\jdk1.8.0_45\bin\javac “$(FILE_NAME)”
C:\Program Files\Java\jdk1.8.0_45\bin\java “$(NAME_PART)”

Notepad++ 3

Replace “C:\Program Files (x86)\Dev-Cpp\MinGW64\bin” and “C:\Program Files\Java\jdk1.8.0_45\bin” with the path where compiler is installed in your computer.

6. Then go to Plugins > NppExec > Advance Options. In the bottom left corner you will get a list of Associated script. Select the script that you have just created from the drop down list.

Notepad++ 4

7. Click on Add/Modify button. Now you can see the script in the Menu items box at the top.

Notepad++ 5

8. Click OK button, you have to restart the notepad++.

9. After that go to Settings > Shortcut Mapper. Click on Plugin commands tab, there you will get the list of all the commands. Scroll down until you see the command with the name with which you have saved the script.

Notepad++ 6

10. Click on Modify button to choose a shortcut according to you. Make sure the shortcut is unique. Now close the window.

Notepad++ 7

11. Just write your program and run it using the shortcut key you created in previous step. You can see the output in the Console window as shown below.

Notepad++ 8

 

So this was the simple method to configure notepad++ to execute C, C++ and Java programs. If you are getting any problem then comment below, I will try to solve your problem.

42 thoughts on “Configure Notepad++ to Run C, C++ and Java Programs

  1. yazan

    i cant find this path in my computer “C:\Program Files (x86)\Dev-Cpp\MinGW64\bin”

    Reply
    1. Admin Post author

      The path will be different for you in your computer. It is the path of the bin directory of compiler. You have to search for it in your computer, make sure you have already installed compiler.

      Reply
      1. gabe

        whaaattt??? You guys are terrible why don’t you give a proper explanation instead ??? What bin directory compiler am i looking for ?? Thanks for the waste of time ? You should put as a heading this instruction makes no sense.

        Reply
        1. John

          A c++ compiler. This is something separate you have to download. If you want to work in c++ you need to download a version of the c++ programming language compiler. The compiler takes the code you write and turns it into a thing that your computer can execute.

          Reply
  2. shubham

    here by compiler you mean notepad++ path because me too having the problem after doing all that setting it giving error that
    CreateProcess() failed with error code 2:
    The system cannot find the file specified.

    help me

    Reply
  3. Nazia

    npp_save
    cd $(CURRENT_DIRECTORY)
    C:\Program Files (x86)\Dev-Cpp
    \MinGW64\bin\g++.exe
    “$(FILE_NAME)”
    cmd /c
    “$(CURRENT_DIRECTORY)\a.exe”
    after writng ths
    i got a save and ok button i m clickng save buton with script name Nazia

    Thn
    npp_save
    cd $(CURRENT_DIRECTORY)
    C:\Program Files\Java\jdk1.8.0_45\bin
    \javac “$(FILE_NAME)”
    C:\Program Files\Java\jdk1.8.0_45\bin
    \java “$(NAME_PART)”

    After writng the above comand again i type script name nazia and click save button…. i didnt get the path name how i can get the path name..
    plz help me out .

    Reply
    1. Admin Post author

      Enter two different names to save because both the scripts are different.

      Reply
  4. kik1n

    It does not let me compile it.
    g++ does not exist.

    I have already installed MinGW and my directory is in C:\MinGW\bin\g++.exe

    Reply
  5. David Bucio

    I am trying to install Notepad++ with MinGW onto a USB so that I can program in C++ while at work or at any other windows computer that I have access to.

    Here are the commands that I have saved as a script under the Nppexec plugin:
    npp_save
    cd $(CURRENT_DIRECTORY)
    G:\Matrix\MinGW\bin\g++.exe “$(FILE_NAME)”
    cmd /c “$(CURRENT_DIRECTORY)\a.exe”

    But whenever I try to compile (Ctrl+Alt+Enter) I get the following error message:
    NPP_EXEC: “C/C++ Compiler”
    NPP_SAVE: G:\test.cpp
    CD: G:\
    Current directory: G:\
    G:\Matrix\MinGW\bin\g++.exe “test.cpp”
    Process started >>>
    g++.exe: error: ôtest.cppö: No such file or directory
    g++.exe: fatal error: no input files
    compilation terminated.
    <<>>
    The filename, directory name, or volume label syntax is incorrect.
    <<< Process finished. (Exit code 1)
    ================ READY ================

    Is there a different or extra command that I need to include in the script to make the compiler run properly from my USB?

    Thanks in advance!

    Reply
    1. Abhishek Dubey

      Did u got the solution because i am getting same error message. Please help. Thank You

      Reply
      1. No Way

        Delete the quotation marks and replace them. They don’t register as quotation marks by notepad++, they register as something else.

        Reply
  6. Abhishek Dubey

    Current directory: C:\Users\Abhishek\Downloads
    C:\MinGW\bin\g++.exe “demo.c”
    Process started >>>
    g++.exe: ôdemo.cö: No such file or directory
    g++.exe: no input files
    <<< Process finished. (Exit code 1)

    this is what i got. How to solve the issue.
    Thanks You

    Reply
    1. Shivam Aggarwal

      I got the same error and solved it myself by just removing the double quotes from { C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe “$(FILE_NAME)” } to { C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe $(FILE_NAME) }.

      Reply
  7. rks

    I have done all the steps, but when i try to run this program it is not running.

    Reply
  8. Tyler

    The reason everyone is having issues with the code is because they have copied and pasted it and the quotes in the code are not right when they have been pasted. Just replace the quotes by typing them in, and it will work.

    Reply
  9. Aryan

    I AM GETTING THIS ERROR
    “NPP_SAVE: C:\Program Files (x86)\Notepad++\change.log
    CD: C:\Program Files (x86)\Notepad++
    Current directory: C:\Program Files (x86)\Notepad++
    C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe “change.log”
    CreateProcess() failed with error code 2:
    The system cannot find the file specified.

    cmd /c “C:\Program Files (x86)\Notepad++\a.exe”
    Process started >>>
    The filename, directory name, or volume label syntax is incorrect.
    <<< Process finished. (Exit code 1)"

    Reply
    1. sunil

      {C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe “$(FILE_NAME)”} change this to {C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe $(FILE_NAME)} and {cmd /c “$(CURRENT_DIRECTORY)\a.exe”} change this to {cmd /c $(CURRENT_DIRECTORY)\a.exe}

      It worked for me….

      Reply
      1. Chris

        Oh yeah it worked for you… LAST ONE IS THE SAME BLOODY DIRECTORY!

        ‘C:\Users\miiwo\Desktop\a.exe”‘ is not recognized as an internal or external command,
        operable program or batch file.

        Reply
  10. Angelica

    i dont know whats wrong… it keeps on giving error that says:

    NPP_SAVE: C:\Program Files (x86)\Notepad++\demo.c
    CD: C:\Program Files (x86)\Notepad++
    Current directory: C:\Program Files (x86)\Notepad++
    C:\Program Files (x86)\Notepad++\notepad++.exe “demo.c”
    Process started >>>
    <<>>
    ‘C:\Users\User\Desktop\a.exe’ is not recognized as an internal or external command,
    operable program or batch file.
    <<< Process finished. (Exit code 1)
    ================ READY ================

    Reply
  11. Talha

    When ever i try to run my code in c++ using notepad++ then i got one message always..”g++ is not recognized as an internal or external command,operable program or batch file”..i have also followed all your given steps but nothing happened. what can i do to run my code.????

    Reply
  12. Aaron

    Does this work with linking multiple c++ files together?

    Reply
  13. khant htet zaw

    I didn’t find NppExec. So, i go to plugins>plugin manager> , . . . . , . . But it is showing “No new plugin avaiable”.
    please help me. what sould i do. . .
    ( please sorry for my english grammer if anythings are wrong)

    Reply
  14. Michael

    I have tried multiple different ways with nothing working. Please help.

    Current directory: C:\cpp
    C:\cygwin64\bin\g++.exe “SoonersSuck.cpp”
    Process started >>>
    g++: error: ΓÇ£SoonersSuck.cppΓÇ¥: No such file or directory
    g++: fatal error: no input files
    compilation terminated.
    <<>>
    The filename, directory name, or volume label syntax is incorrect.
    <<< Process finished. (Exit code 1)
    ================ READY ================

    Reply
    1. Naveen

      Remover the “” alone in the script from “SoonersSuck.cpp”.

      Try:
      C:\cygwin64\bin\g++.exe SoonersSuck.cpp

      Reply
  15. Parth Shah

    I did it for java but it does not work. The path I entered is completely correct. It give the following message when pressing the shortcut key…

    NPP_EXEC: “Java”
    NPP_SAVE: D:\Java\shapes.java
    CD: D:\Java
    Current directory: D:\Java
    C:\Program Files\Java\jdk\bin\javac “shapes.java”
    Process started >>>
    javac: invalid flag: ôshapes.javaö
    Usage: javac
    use -help for a list of possible options
    <<>>
    Error: Could not find or load main class ôshapesö
    <<< Process finished. (Exit code 1)
    ================ READY ================

    Reply
  16. AXOMME

    This is the correct form of the scripts:
    ———-c++——————————————-
    npp_save
    cd “$(CURRENT_DIRECTORY)”
    C:\MinGW\bin\g++ “$(FILE_NAME)” -o $(NAME_PART)
    cmd /c $(NAME_PART).exe
    ———–Java—————————————–
    npp_save
    cd “$(CURRENT_DIRECTORY)”
    C:\Program Files\Java\jdk1.8.0_65\bin\javac $(FILE_NAME)
    C:\Program Files\Java\jdk1.8.0_65\bin\java $(NAME_PART)

    In the java bit you should place the complete path to your jdk directory, I personally have that path and version so you should change yours to what you have and where you have it. (I’d also consider installing the environment variables for both minGW and jkd in your system)

    Reply
  17. Hiresh

    Everything has been installed as mentioned but after running the script I get “could not find or load main class Test”…kindly help

    Reply
  18. Nikhil Kohli

    NPP_EXEC: “JAVA”
    NPP_SAVE: C:\Users\kohli\Desktop\Nikhil.java
    CD: C:\Users\kohli\Desktop
    Current directory: C:\Users\kohli\Desktop
    C:\Program Files\Java\jdk1.8.0_60\bin\javac “Nikhil.java”
    Process started >>>
    javac: invalid flag: ôNikhil.javaö
    Usage: javac
    use -help for a list of possible options
    <<>>
    Error: Could not find or load main class ôNikhilö
    <<< Process finished. (Exit code 1)
    ================ READY ================

    Write this code

    import java.util.*;

    public class Nikhil {
    public static void main(String[] args){
    System.out.print("Nikhil");
    }
    }

    help me

    Reply
  19. Manug

    Please tell me how can i get filename without its extension or how to remove it cause i want to compile files using each names as output name

    Reply
  20. Ajay

    Who ever is facing issue while compiling with MinGW compiler .. Please follow this… It works for me
    npp_save
    cd $(CURRENT_DIRECTORY)
    C:\MinGW\bin\g++.exe “$(FILE_NAME)”
    cmd /c “$(CURRENT_DIRECTORY)\a.exe”

    Reply
  21. Scarlett

    Mine says
    The program can’t start because libiconv-2.dll is missing from your computer. Try reinstalling the program to fix this problem.

    Do I reinstall Notepad++ or MinGW?
    Is there another way to fix this?

    Reply
  22. Marlene Carney

    Here’s what I am getting, where is my mistake?

    CD:
    Current directory: C:\Program Files (x86)\Notepad++
    C:\Program Files\Java\jdk1.8.0_101\bin\java “new 1
    Process started >>>
    Error: Could not find or load main class new 1
    <<< Process finished. (Exit code 1)
    ================ READY ================

    Reply
    1. Renuprasad

      @Malen Carney

      Remove those double quotes in the script you added
      C:\Program Files\Java\jdk1.8.0_45\bin\javac “$(FILE_NAME)”
      C:\Program Files\Java\jdk1.8.0_45\bin\java “$(NAME_PART)”

      change this to
      C:\Program Files\Java\jdk1.8.0_45\bin\javac $(FILE_NAME)
      C:\Program Files\Java\jdk1.8.0_45\bin\java $(NAME_PART)

      and save it. Hope this helps

      Reply
  23. RGB

    NPP_SAVE: D:\Teaching\Nepal\PGM\C\asci2char.c
    CD: D:\Teaching\Nepal\PGM\C
    Current directory: D:\Teaching\Nepal\PGM\C
    C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe “asci2char.c”
    Process started >>>
    g++.exe: error: ôasci2char.cö: No such file or directory
    <<>>
    The filename, directory name, or volume label syntax is incorrect.
    <<< Process finished. (Exit code 1)
    ================ READY ================

    Reply
  24. shilps

    I have tried it and it works. But when the c programs are written for printing its showing the output below but when I’m trying it with scanf it’s not returning anything.. So is there any way to put values manually like using scanf?

    Reply
  25. Suayb Yurdakul

    N++ tells me that I’m missing .dll’s that are contained in the MingW/bin/ directory. I’ve tried copying them into Windows/System32/ but it still isn’t able to find them.

    I’m using MingW 2013-10-26, Notepad++ 6.9.2 and NppExec 0.5.3

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *