How to fix "'java' is not recognized as an internal or external command, operable program or batch file" when trying to start PaperMC Server?



  • I'm running a PaperMC server as the title suggests, but whenever I try running the server via the batch file I get this error:

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

    The text in the batch file is:

    java -Xmx4096M -Xms4096M -jar paper.jar nogui
    PAUSE
    

    Help would be greatly appreciated and I can supply more information if needed.



  • It sounds like Java is either not installed on the machine, or it's not added to PATH - in other words, Windows can't find the Java executable.

    If you type in a command prompt https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/where java, if Java is installed, you should get back a file path of where the Java executable is. Take note of this file path. At this point you have two options:

    1. Update your batch file to change directory (cd) to the path of where the Java executable is prior to calling java.
    2. Add the path to your PATH environment variables, which makes the executable accessible from any path. https://www.java.com/en/download/help/path.html has a guide on how to do this:
    1. In Search, search for and then select: System (Control Panel)
    2. Click the Advanced system settings link.
    3. Click Environment Variables. In the section System Variables find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
    4. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
    5. Reopen Command prompt window, and run your java code.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2