views
- 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.
Getting What You Need
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: Java RTE: https://www.java.com/en/download/manual.jsp Java SDK: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
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.
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).
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.
Click the checkbox next to "NppExec" and click Install. NppExec is the plugin that is needed to compile and run Java programs in Notepad++.
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.
Setting the Environment Variables
Open File Explorer Windows File Explorer. 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.
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.
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.
Click Environment Variables. It's near the bottom of the System Properties menu.
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.
Type JAVA_HOME next to "Variable Name." It's the first bar at the top.
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.
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.
Click Ok. This saves the new system variable.
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.
Click New. It's the first option to the right. This creates a new blank environment variable at the bottom.
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.
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
Click Ok. It's at the bottom of the environment variables menu. This saves all of your changes and closes the menu.
Compiling a Java Program in Notepad++
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).
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.
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.
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.
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: cd $(CURRENT_DIRECTORY) javac $(FILE_NAME) java $(NAME_PART)
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.
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.
Click Save. This saves the script used to compile Java programs.
Click Ok. This displays the console at the bottom of Notepad++ and compiles the program.
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.
Comments
0 comment