Notepad++ is a free text and source code editor for Windows. You can use Notepad++ to write programs in Java and other programming languages. Using a plugin called "NppExec", you can compile and run Java programs using Notepad++. You'll need to have the proper Windows environment variables set up on your computer in order to do so. You will also need to write a short script to compile and run Java programs using the plugin. This wikiHow teaches you how to set to your system variables and compile and run Java programs in Notepad++

Things You Should Know

  • You'll need the latest version of Java SDK, Java RTE, Notepad++, and NppExec (the plugin for Notepad++).
  • Change your computer's environment variables to allow for creating and running Java.
  • Write Java code in Notepad++, save it as a Java file, then launch the NppExec plugin.
Part 1
Part 1 of 3:

Getting What You Need

  1. 1
    Make sure you have the latest version of Java SDK and Jave RTE. Java Software Development Kit (SDK) allows you to write programs for Java on your computer. Java Runtime Environment allows you to run Java programs on your computer. Even if you have both installed on your computer, check to make sure you are running the latest version of both Java SDK and Java RTE. You can download and install both Java SDK and Java RTE from the following links:
  2. 2
    Download and install Notepad++. Notepad++ is not the same as Notepad that comes pre-installed on most Windows computers. Notepad++ is a separate free program you need to download and install. Notepad++ has autofill options for Java and other programming languages. It also allows you to install plugins that can be used to compile Java and other languages. You cannot compile Java in the regular version of Notepad. Use the following steps to download and install Notepad++:
    • Go to https://notepad-plus-plus.org/downloads/ in a web browser.
    • Click the latest release of Notepad++ at the top of the list.
    • Scroll down and click Installer below "Download 64-bit x64."
    • Click the installer file in your web browser or Downloads folder.
    • Follow the instructions to complete the installation.
    Advertisement
  3. 3
    Open Notepad++. It has an icon that resembles a pencil drawing on a sheet of paper. Use the following steps to open Notepad++:
    • Click the Windows Start icon.
    • Type "Notepad".
    • Click the Notepad++ icon (not Notepad).
  4. 4
    Open the Plugins Admin or Plugins Manager. The Plugins Admin or Plugins Manager allow you to install plugins for Notepad++. If you are using a newer version of Notepad++, this is listed as "plugins Admin." On older versions of Notepad++, it will be listed as "Plugins Manager." Use the following steps to open the Plugins Admin or Manager:
    • Click Plugins in the menu bar at the top.
    • Click Plugins Admin or Plugins Manager.
    • Click Show Plugins Manager.
  5. 5
    Click the checkbox next to "NppExec" and click Install. NppExec is the plugin that is needed to compile and run Java programs in Notepad++.
  6. 6
    Click Yes. This confirms you want to install the plugin and installs the NppExec. It will take a few minutes for the plugin to finish installing. Notepad++ will restart when the installation is complete.
  7. Advertisement
Part 2
Part 2 of 3:

Setting the Environment Variables

  1. 1
  2. 2
    Right-click "This PC" and click Properties. "This PC" is in the menu bar to the left. Right-click this option to display a pop-up menu. Then click Properties at the bottom of the pop-up menu. This opens the "About" menu in Windows Settings.
  3. 3
    Click Advanced system settings. It's in the menu to the right below "Related settings" menu on the right. This opens the System Properties menu.
  4. 4
    Click Environment Variables. It's near the bottom of the System Properties menu.
  5. 5
    Click New below the System Variables box. There are two boxes in the Environment Variables menu. The one labeled "System Variables" is the one on the bottom. This opens a dialogue box that allows you to create a new system variable.
  6. 6
    Type JAVA_HOME next to "Variable Name." It's the first bar at the top.
  7. 7
    Click Browse Directory. It's the first button on the bottom. This opens a file browser that allows you to browse to the location of your Java installation.
  8. 8
    Click the folder containing your Java installation and click Ok. On most Windows computers, you can find the Java installation by opening the following folders
    • Click This PC.
    • Click C:(OS).
    • Click Program Files.
    • Click Java.
    • Click jdk-[latest version]
    • Click Ok.
  9. 9
    Click Ok. This saves the new system variable.
  10. 10
    Click the "PATH" system variable and click Edit. It's the variable labeled "Path" is in the box on the bottom. Click this variable to select it. Then click Edit below the box on the bottom.
  11. 11
    Click New. It's the first option to the right. This creates a new blank environment variable at the bottom.
  12. 12
    Type %JAVA_HOME%\bin and click Ok. This is the text you need to use to fill in the blank new system variable at the bottom. This creates a new environment variable that allows NotePad++ to access the "bin" folder.[1]
  13. 13
    Click Ok. It's in the lower-right corner at the bottom of the "edit environment variables" menu. This saves the new environment variable path
  14. 14
    Click Ok. It's at the bottom of the environment variables menu. This saves all of your changes and closes the menu.
  15. Advertisement
Part 3
Part 3 of 3:

Compiling a Java Program in Notepad++

  1. 1
    Open Notepad++. It has an icon that resembles a pencil drawing on a sheet of paper. Use the following steps to open Notepad++:
    • Click the Windows Start icon.
    • Type "Notepad".
    • Click the Notepad++ icon (not Notepad).
  2. 2
    Use Notepad++ to write a Java program. Use Notepad++ to enter your Java code. It works like a regular Notepad, but also has predictive text and autofill features for most programming languages. This makes it much easier to write code in Notepad++ rather than regular Notepad.
  3. 3
    Save your program as a Java file. It is recommended that you create a specific folder on your computer to save your Java program files in. Use the following steps to save your text files as Java files:
    • Click File in the menu bar at the top.
    • Click Save as in the drop-down menu.
    • Select the folder you want to save your file in.
    • Type a name for your file next to "File name."
    • Select Java source file (*.java) in the drop-down menu next to "Save as Type."
    • Click Save.
  4. 4
    Launch the NppExec plugin. You can do so in the plugins menu. Use the following steps to execute the NppExec plugin:
    • Click Plugins in the menu bar at the top.
    • Hover your mouse cursor over NppExec.
    • Click Execute.
  5. 5
    Type the following commands in the Command(s) box. This is the script needed to compile Java programs. There are three commands you need to type. The first command opens the directory the current Java file is saved to. The second command compiles the current Java file. The third command executes the main class in the Java file. Place each of these commands on a separate line. Type each of the following commands and press Enter:[2]
    • cd $(CURRENT_DIRECTORY)
    • javac $(FILE_NAME)
    • java $(NAME_PART)
  6. 6
    Click Save. It's the second button at the bottom of the screen. This displays a pop-up that allows you to name the script.
  7. 7
    Type Java_Compile_Run as the script name and click Save. This gives the script a name. You can reuse this script anytime you need to compile a Java program inside Notepad++. It's a good idea to name it something that indicates that this script compiles Java programs.
  8. 8
    Click Save. This saves the script used to compile Java programs.
  9. 9
    Click Ok. This displays the console at the bottom of Notepad++ and compiles the program.
  10. 10
    Compile Java programs using the Java_Compile_Run script. Use the following steps to compile future programs using this script you just created:
    • Click Plugins in the menu bar at the top.
    • Hover over NppExec.
    • Click Execute
    • Select "Java_Compile_Run" in the drop-down menu at the bottom.
    • Click Ok.
  11. Advertisement

Community Q&A

  • Question
    Do I need to install the JDK?
    JumpingDragon
    JumpingDragon
    Community Answer
    Yes, you will need the JDK for any sort of programming, modding, or compiling software.
  • Question
    What are the basics of Java programming?
    Community Answer
    Community Answer
    It would be helpful to learn basic data structures like integers, doubles, and strings, and how to manipulate them with math and functions.
  • Question
    How can I run the code if I don't have the plugin installed or can't install it?
    RainbowMineBear 09
    RainbowMineBear 09
    Community Answer
    You can't.
Advertisement

Warnings

  • Notepad++ is a light program. So it is hard to run a huge Java project. However, a normal Java class file that is under 10 MB should work fine.
    ⧼thumbs_response⧽
Advertisement

About This Article

Travis Boylls
Written by:
wikiHow Technology Writer
This article was co-authored by wikiHow staff writer, Travis Boylls. Travis Boylls is a Technology Writer and Editor for wikiHow. Travis has experience writing technology-related articles, providing software customer service, and in graphic design. He specializes in Windows, macOS, Android, iOS, and Linux platforms. He studied graphic design at Pikes Peak Community College. This article has been viewed 144,366 times.
How helpful is this?
Co-authors: 10
Updated: October 25, 2022
Views: 144,366
Categories: Java
Article SummaryX

1. Download and install Notepad++.
2. Install the "NppExec" plugin from Plugins Admin.
3. Execute NppExec and enter the commands: "cd $(CURRENT_DIRECTORY)", "javac $(FILE_NAME)", "java $(NAME_PART)".
4. Save the script in NppExec.
5. Write a simple Java program in Notepad++.
6. Save the text file as a ".java" file.
7. Use the script in NppExec to compile the program.

Did this summary help you?
Advertisement