NotePad++ - How To Add Java Compiler


1) Install NppExec PlugIn

If you haven't installed NppExec PlugIn, follow this tutorial,, before proceeding to the next step.

2) Configure the NppExec Plugin

Go to Plugins > NppExec and apply the followings:
1. Disable "Console Command History"
2. Enable "Save all files on execute"
3. Enable "Follow $(CURRENT_DIRECTORY)"

3) Add Compile command

3.1. Go to Plugins > NppExec > Execute...
3.2. Choose “Cancel” if  a Save File… dialog box appears
3.3. Enter the following command:
javac $(FILE_NAME)
3.4. Click Save. Type the name as "Compile".

4) Add Run command


5) Add Compile and Run command

javac $(FILE_NAME)
java $(NAME_PART)

6) Add the Execute Command Names as menu.

6.1) Go to NppExec Advance Options:
6.2)  enable "Place to the Macros submenu".
6.3) Then select “Compile” from under the “Associated script:” menu, and click the
“Add/Modify” button:
6.4) Repeat this process for the other two scripts, be careful to type the names “Run” and
“Compile and Run” in the “Item name:” box before hitting the Add/Modify button.

7) Restart Notepad++

8) Test by creating Test.Java file.

public class Test {
public static void main(String[] args) {
System.out.println("Hello world!");

9) Compile

Go to menu  Macro/Compile.
9.1) In case you get an error like “Unknown command”:
9.1.1) Change your command as follows:
C:\Program Files\Java\jdk1.7.0_21\bin\javac $(FILE_NAME)
It could be caused by Windows not knowing the path to javac program (possibly true when you are using Notepad++ Portable Version, because it is running in its own memory container).
10) A successful Compile Command would result as follow:
11) A successful Compile and Run Command would result as follow:
This article was originally posted by me at:

Post a Comment