search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

Table of Contents
1. Install Java Development Kit (JDK)
2. Write Java Code in Notepad
3. Compile and Run Using NPPExec Plugin
4. Shortcut for One-Click Execution
Home Development Tools notepad How to run a Java program from Notepad

How to run a Java program from Notepad

Jan 17, 2026 am 12:24 AM

Install JDK and set JAVA_HOME and PATH. 2. Write Java code in Notepad and save as HelloWorld.java. 3. Use NPPExec plugin to run commands: cd "$(CURRENT_DIRECTORY)", javac "$(FILE_NAME)", java "$(NAME_PART)". 4. Save script and assign shortcut for one-click compile and run.

How to run a Java program from Notepad

To run a Java program from Notepad , you don't need an IDE like Eclipse or IntelliJ. You can write, compile, and execute Java code directly using Notepad and the command-line tools included with the JDK. Here's how.

1. Install Java Development Kit (JDK)

Before running Java from Notepad , ensure the JDK is installed on your system.

  • Download the JDK from the Oracle or OpenJDK website.
  • Install it and make sure to set the JAVA_HOME environment variable.
  • Add the bin folder of the JDK (e.g., C:\Program Files\Java\jdk-xx\bin) to your system's PATH environment variable.

Verify installation by opening Command Prompt and typing:

java -version
javac -version

You should see version info for both.

2. Write Java Code in Notepad

Open Notepad and write a simple Java program. For example:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

Save the file as HelloWorld.java in a folder of your choice (e.g., C:\JavaPrograms). Make sure the file name matches the class name exactly, including case.

3. Compile and Run Using NPPExec Plugin

Notepad has a plugin called NPPExec that allows executing external commands, such as compiling and running Java.

  • Go to PluginsNPPExecExecute (or press F6).
  • In the script window, enter the following commands:
cd "$(CURRENT_DIRECTORY)"
javac "$(FILE_NAME)"
java "$(NAME_PART)"

This tells the system to:

  • Change directory to where your Java file is saved.
  • Compile the Java file using javac.
  • Run the compiled class using java.

Click Save and give the script a name like "Run Java". You can now run this script anytime with a shortcut.

4. Shortcut for One-Click Execution

To make it faster:

  • After saving the NPPExec script, go to PluginsNPPExecAdvanced Options.
  • Under "Menu items", select your saved script and click "Add/Modify" to add it to the menu.
  • Optionally assign a shortcut key via SettingsShortcut MapperPlugin Commands.

Now you can compile and run your Java program with just one click or keystroke.

Basically, Notepad becomes a lightweight Java coding environment when combined with JDK and NPPExec. It’s fast, simple, and great for learning or small projects.

The above is the detailed content of How to run a Java program from Notepad. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

ArtGPT

ArtGPT

AI image generator for creative art from text prompts.

Stock Market GPT

Stock Market GPT

AI powered investment research for smarter decisions

Popular tool

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)