Use Notepad++ to Compile and Run Java Programs

Notepad++ can run the programs of different languages if the corresponding plugin is installed. This tutorial will demonstrate how to compile and run Java programs in Notepad++.
Use Notepad++ to Compile and Run Java Programs
The following are steps to use Notepad++ to compile and run your Java programs.
-
Prerequisites
If you haven’t already installed Java and Notepad++, the first step is to install JDK and Notepad++.
Download and install JDK, Java Runtime Enviroment, and Notepad++.
Once the pre-requisites are installed, we can go to the next step.
-
Install NppExec Plugin in Notepad++
Go to the
Plugins
menu optionPlugins Admin
and install theNppExec
plugin.Don’t be confused with the second picture. If the
NppExec
is already installed, it will not be shown in the list. Notepad++ will be closed to install the plugin; once the plugin is installed, go to the next step. -
Set Environment Variables
Go to the start menu and search
Environment Variable
and open as mentioned in the pictures below:In the user variable section, click new and add the
JAVA_HOME
variable; the directory should be your JDK directory:Now press
edit
for the path in the system variables list:Click New and add
%JAVA_HOME%\bin
then click ok three times till the properties menu is closed:At this moment, you will need to restart your pc so the environment variables can work properly.
-
Run Java Program on Notepad++
In Notepad++, create a new file, write a Java program, and save it with a
.java
extension, which is, in our case,Java_notepadpp.java
.Once the program is saved, go to
plugins
and openExecute NppExec Script
fromNppExec
.Write the following command in the box opened:
cd $(CURRENT_DIRECTORY) javac $(FILE_NAME) java $(NAME_PART)
Save the commands as
Java_Run
.Once the commands are saved, we can now run Java programs. Go to
plugins
and openExecute NppExec Script
fromNppExec
.Select
Java_Run
and click ok to run the Java file in the console; see the output below.The Java program is successfully compiled in Notepad++. Now, you can run Java programs in Notepad++.
Here is another example:
public class Java_notepadpp { public static void main(String args[]) { System.out.println("This is a demo to run the JAVA program in Notepad++"); } }
Let’s run and get the output:
The Java program is successfully compiled in Notepad++.
Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.
LinkedIn Facebook