1

Здравствуйте! В общем пытаюсь настроить VS Code для компиляции java-файлов. Установил расширения:

  1. Language Support for Java(TM) by Red Hat
  2. Java Debug

В настройках VS Code прописал путь к JDK:

"java.home": "C:\\Program Files\\Java\\jdk1.8.0_131"

Пишу обычный Hello world -> Alt+C -> Выдает ошибку:

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

Кто сталкивался с подобным? Толковой пошаговой инструкции настройки VS Code под Java так и не нашел.

1 ответ 1

2

VSCode пытается запустить javac, но не знает, в какой директории он лежит. Для обнаружения бинарников в таких ситуациях в операционных системах есть переменная окружения PATH - она содержит все директории, в которых могут оказаться искомые бинарники. Таким образом вам нужно отредактировать переменные окружения, добавив в PATH C:\Program Files\Java\jdk1.8.0_131 (или поддиректорию, в которой находится javac.exe). Конкретные действия для редактирования переменных окружения могут разниться в зависимости от версии Windows, поэтому мне ничего не остается кроме как скопировать содержимое https://www.java.com/en/download/help/path.xml

Windows 10 and Windows 8

  • In Search, search for and then select: System (Control Panel)
  • Click the Advanced system settings link.
  • 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.
  • 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.
  • Reopen Command prompt window, and run your java code.

Windows 7

  • From the desktop, right click the Computer icon.
  • Choose Properties from the context menu.
  • Click the Advanced system settings link.
  • 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.
  • 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.
  • Reopen Command prompt window, and run your java code.
1
  • Спасибо за ответ! Помогло добавление в PATH C:\Program Files\Java\jdk1.8.0_131\bin
    – user271163
    15 ноя 2017 в 17:44

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.