-1

I'm following the w3schools tutorial on Java and it says to make a Java file (called "Main.java") containing:

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

Then it says to enter "javac Main.java" into command prompt, but it's not working command prompt

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

2 Answers2

0

For the shown image, it is saying javac is not on your OS PATH for executables. You need to use Control Panel to configure this.

Java developers don't regularly use CMD to run Java code, though. For starting out, you should ideally use an IDE like IntelliJ, Netbeans, Eclipse, VSCode, etc, which all have documentation getting started with Java development. And each have a simple run button to execute both javac and java.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
0

It seems like Java bin wasnt added into System Path.

The default installation folder for Java is smth like C:\ProgramFiles\Java\jdk<version>\bin

You can check that javac is there, add C:\ProgramFiles\Java\jdk<version>\bin to the System Path and (optionally) reboot your PC, because Windows has troubles with Path without a reboot.

excommunicado
  • 287
  • 1
  • 10