PDF download Download Article PDF download Download Article

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++

Running Java Programs with Notepad

  1. Get the latest version of Java SDK, Java RTE, Notepad++, and NppExec (the plugin for Notepad++).
  2. Change your computer's environment variables to allow for creating and running Java.
  3. 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

PDF download Download Article
  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. 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. 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. 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. NppExec is the plugin that is needed to compile and run Java programs in Notepad++.
  6. 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

PDF download Download Article
  1. It has an icon that resembles a folder with a blue clip. You can click the icon in the taskbar at the bottom or press Windows Key + E to open File Explorer.
  2. "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. It's in the menu to the right below "Related settings" menu on the right. This opens the System Properties menu.
  4. It's near the bottom of the System Properties menu.
  5. 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. It's the first bar at the top.
  7. 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. 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. This saves the new system variable.
  10. 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. It's the first option to the right. This creates a new blank environment variable at the bottom.
  12. 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. It's in the lower-right corner at the bottom of the "edit environment variables" menu. This saves the new environment variable path
  14. 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++

PDF download Download Article
  1. 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. 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. 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. 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. 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. It's the second button at the bottom of the screen. This displays a pop-up that allows you to name the script.
  7. 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. This saves the script used to compile Java programs.
  9. This displays the console at the bottom of Notepad++ and compiles the program.
  10. 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

Search
Add New Question
  • Question
    Do I need to install the JDK?
    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
    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
    Community Answer
    You can't.
See more answers
Ask a Question
      Advertisement

      Video

      Tips

      • There are other plugins for Notepad++ that can compile Java programs. However, NppExec is the one that is most commonly recommended.


      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Name
      Please provide your name and last initial
      Thanks for submitting a tip for review!
      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.
      Advertisement

      About This Article

      Article Summary X

      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?
      Thanks to all authors for creating a page that has been read 202,451 times.

      Is this article up to date?

      Advertisement