Run java code from Notepad++ – One click Run and Compile


Running a java code from Notepad is always a good practice, especially for beginners. There are several reasons. I hope you all have used modern IDEs like NetBeans and Eclipse. Well, these are no doubt excellent IDEs with lots of features, but if you are a beginner then these are not a good option to do programming. Because all these IDEs have auto-complete feature, you just type few letters and the line is completed automatically, which is absolutely not good for beginners. Always remember our mind remembers those things which we practice a lot. You won’t be able to learn things or remember things if you always select things from the drop-down menu in IDEs. If you are a beginner or just started to learn programming and using those modern  IDEs, then it is like spoon feeding when you don’t even know how to hold a spoon.

Here’s another reason, modern IDEs use so much RAM. If you have a PC with 1-2 gigs of RAM it will take lots of time to load the IDE. So a lightweight notepad is always a good option.

Read this full article and try running Java code from NotePad++ and any other IDE. You will see the difference.

So my suggestion is to use a text editor like  NotePad++ rather than using any of those IDEs like NetBeans or Eclipse.

Now that you know why I am suggesting a notepad to do Java programming, it’s time to install the notepad and get started with it.

First of all, you need to install Notepad++ on your computer. You can download the setup file from the official site of Notepad++.

After downloading the setup file simply install it by double-clicking.

Now that you have installed notepad++, we have to do few simple things to run java code. Follow the steps below:

1. To run a java code your PC needs to be configured environment variable. If you are not sure about that you can check our article on Java Environment Variable.

2. Now open Notepad++ and go to Plugins – Plugin Manager – Show Plugin Manager.

3. From Plugin Manager window we have to install three plugins.

i)   Compare – This plugin is used to show the difference between two files.

ii)  NppExec – This plugin is necessary to execute java code.

iii) HEX-Editor.

4. From the Available plugins tab, search for the above three plugins and install.

5. After installing all three plugins, click on PluginNppExecExecute.

6. Execute window will open. In the command line type the below code and click Save.

7. Type the name as you want. Like Java_Compile. Click Save then click Cancel.

8. Again do the same steps as above. Go to PluginsNppExecExecute.

Type the below code in the command line and click Save.


9. Name it as you want, like Run-Java or Java-Run then click Save and then click on Cancel.

10. We are almost done. Now we have to add those two Options under Macro tab. To do so, Go to PluginsNppExecAdvanced Options. NppExec Advanced Options window will open.

11. At the bottom of the window select, Java-Compile (or whatever you have named the script) from the Associated Script drop-down menu and select Add / Modify.

Tick Place to the Macros submenu under Menu items* and click Ok. The window will be closed.

12. Do the same steps as above to add the Java-run (or whatever you have named the script).

Go to PluginsNppExecAdvanced Options.

Now select your script from the Associated script drop-down menu.

Click Add / Modify. Tick Place to the Macros submenu and then click Ok.

That’s all. Restart your NotePad++ and Run your java code.

Now we are going to test a java code to see whether it’s working or not.

Open NotePad++ – type any code and Save it anywhere as .java.

To run the code click Macro – Java-Compile then Macro – Java-run.

After running the program you will see the output at the bottom of the screen.


You May Also Like

Leave a Reply

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