Click here to Skip to main content
15,559,544 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to practice java code in notepad using command prompt and l have installed jdk 16 for that. But do l first need to set up the environmental variables for running program in notepad?? I tried running program in notepad without setting environmental variables for jdk but didn't worked

What I have tried:

I tried running program in notepad using command prompt but didn't worked. It was saying that you can't save your java file in jdk bin. Grant permission first
Updated 9-Jul-21 23:31pm

You can't run Java in Notepad - it's a basic editor and not an IDE.
What you can do is edit your Java code in Notepad, save it, go to a command prompt, change to the right folder (where you saved your Java code file), compile it, and run it: How to Run Java Program in CMD Using Notepad - Javatpoint[^]

Do compile and run teh code, you need to j=have Java installed, and it will need the environment variables set correctly: Steps to Run Java Program using Command Prompt[^]

Would I bother? No. I'd install Eclipse Downloads | The Eclipse Foundation[^] instead as it includes the debugger, compiler, and editor in a single package ... much easier to play with!
Share this answer
[no name] 10-Jul-21 1:35am    
Thanks for helping me but l tried installing eclipse and sublime text but they are not supporting my version that is 1607. So can you suggest me some applications or code editors that is compatible with my version
OriginalGriff 10-Jul-21 1:46am    
Google for "Java IDE" and you'll find quite a few.
Create a new folder in your Documents folder (e.g. samples), and open a command prompt window there. Create your source program and save it in that folder. Then in the command window type the following:
javac <your source file name>.java

That will compile the program and show you any errors. Fix the errors and repeat the process until there are no errors. You can then run your program with the command:
java <your source file name>

Make sure that the file name is the same as the class name in your code. For example:
import java.util.Scanner;

class Test {

    int doTest() {
        int rc = 0;

        // test code goes in here

        return rc;

    public static void main(String[] argv) {
        Test javaTest = new Test();
        int result = javaTest.doTest();
        System.out.printf("Java test result: %d\n", result);


This code must be saved in a file named

I use Visual Studio Code as my development environment for Java, which provides a command window as standard option.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900