Debug/run standard java in Visual Studio Code IDE and OS X?

前端 未结 3 1414

Love the light-weight Visual Studio Code in OS X. Have always wanted the ability to write, debug and run standard java (NOT javascript) from VSC in OS X. Found the following

3条回答
  •  臣服心动
    2020-12-13 01:19

    I can tell you for Windows.

    1. Install Java Extension Pack and Code Runner Extension from VS Code Extensions.

    2. Edit your java home location in VS Code settings, "java.home": "C:\Program Files\Java\jdk-9.0.4".

    3. Check if javac is recognized in VS Code internal terminal. If this check fails, try opening VS Code as administrator.

    4. Create a simple Java program in Main.java file as:

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

    Note: Do not add package in your main class.

    1. Right click anywhere on the java file and select run code.

    2. Check the output in the console.

    Done, hope this helps.

提交回复
热议问题