Compiling and running Java code in Notepad++

Viewed 409

I got a new computer and I'm trying to get Notepad++ to run how it did on my old one. I got the NPPExec plugin. When I click Execute, it brings up the commands I want to enter. My goal here is to have the code save, compile, and run in the console of Notepad++. Currently I have what I thought used to work on my old laptop.

cd $(CURRENT_DIRECTORY)

javac $(FILE_NAME)

java $(NAME_PART)

Whenever I try and execute it though, I get

Current directory: C:\Directory
javac HelloWorld.java
; about to start a child process: "javac HelloWorld.java"
CreateProcess() failed with error code 2:
The system cannot find the file specified.

java HelloWorld
; about to start a child process: "java HelloWorld"
CreateProcess() failed with error code 2:
The system cannot find the file specified.

I've tried it on files I used to have, and just a basic Hello World

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

I don't get what the problem is, and would love if someone would be able to help.

Edit: I am using Windows

After checking here: https://beginnersbook.com/2013/05/first-java-program/ and seeing the Set Path section, I reinstalled Java, did the set path command, although the file path ended at \Java and did not have that whole JDK bit in it. I'm not sure if that's part of the issue and Java is not installed properly.

Edit 2: Tried to Find where I can install JDK, and everything sent me to Oracle's website. Is this needed?

Edit 3: Well, I tried just executing the javac command through command prompt and got

'javac' is not recognized as an internal or external command, operable program or batch file.

So I'm pretty sure it's the issue with JDK not being in the folder. I went to check my old laptop, and it didn't have JDK in the folder either. It gives the same error when using the javac command, but for some reason the java command works fine to execute the file. Do I really have to create an Oracle account just to get JDK? When I went to sign up it wanted my work phone number, so it definitely didn't seem like a free thing.

Edit 4: I tried following the Oracle documentation on installing a jdk. I did the download from there, but following that, I didn't see the file I needed. In the Java folder, there is now the jdk-16 folder. In the bin folder there, there are a number of .exe files, but I don't know if any of them are the ones I'm supposed to run. Now that I've installed it though, I'm still getting an error with javac command, but the java command will run files I'd previously compiled.

0 Answers
Related