Compile and execute programs in Notepad++

/
0 Comments
Are you a fan of Notepad++ ? (Me too ..:P). Here is a cool Notepad++ trick for programmers. You can compile and execute you programs using your favorite editor. How? Let's see. ;)


1) Install and configure JDK:(If you have already installed JDK then skip this step.)

Download and install latest version of JDK from this link if you are not having Java already installed.

Set PATH variable to point to JDK binaries. Check this link.
To check whether PATH is set properly fire 'javac' command in CMD and the output should look like this:

 2) Install Notepad++: (Skip is already having Notepad++)

Download latest version of Notepad++ from here and install it.



3) Install NppExec plugin in Notepad++:

Open Notepad++ and go to Plugins>> Plugin manager>> Show plugin manager. 





That will open Plugin Manager.





Find NppExec from the list and install it.


After completing installation it will prompt you to restart Notepad++. Say "Yes".


Once restarted Notepad++, NppExec is installed.

4) Configure NppExec to compile and execute Java programs.

Go to Plugins>>NppExec>>Execute. (or press F6).

It will open this window.


Paste this code:

NPP_SAVE

cd "$(CURRENT_DIRECTORY)"
javac  $(FILE_NAME)


And press Save button to save this script.

 Save it with compile-java name.(or any other convenient name).

From dropdown choose "temporary-script" and paste this code:

java -classpath "$(CURRENT_DIRECTORY)" "$(NAME_PART)"
 Save it with name 'compile-java' (or any other name you find convenient).



After saving close Execute window.

5) Add compile and run options as menu items

Go to Plugins>> NppExec>> Advanced Options.


 It will open following window.
Check the Place to the Macro submenu option.

 Give menu name in "Intem name" e.g. Compile-java.

Choose script "Compile-java" from dropdown.

 Click Add/Modify.

Repeat same steps for Run-java script. You will have two menu items.

Press OK and restart Notepad++.

6) Testing with sample Java program:

After restarting Notepad++ create a sample java program:

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


Save the file.

Go to Macro menu. You will find our new menu items added.

Press "Compile-java" to compile the code.




 After compiling press "Run-java" to see the output in consol.


Bingo!!!


You can follow similar steps for other programing languages also.

Trouble or suggestions??? Throw them in comment section... :)


Reference: https://www.cs.auckland.ac.nz/courses/compsci101s1c/resources/Notepad/Notepad++.pdf





You may also like

Popular Posts