Reputation: 606
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 extension which allows you to debug and run java from VSC:
https://marketplace.visualstudio.com/items?itemName=donjayamanne.javadebugger
Followed the directions as best as I could. Trying to run my java app, and I am getting a bunch of "error: cannot find symbol" errors in the debug-console window when I run my java app in VSC from OS X. App runs great in eclipse. What am I missing in either VSC or somewhere in OS X so I can properly run java code from VSC in OS X?
Upvotes: 38
Views: 164336
Reputation: 677
In the extensions tab, there is Java Extension Pack published by Microsoft for Visual Studio Code. It installs 6 extensions for Java development (Language Support, Debugger, IntelliCode etc.). I used it for the first time and found it quite easy to install.
Upvotes: 0
Reputation: 7667
I can tell you for Windows.
Install Java Extension Pack and Code Runner Extension from VS Code Extensions.
Edit your java home location in VS Code settings, "java.home
": "C:\\Program Files\\Java\\jdk-9.0.4"
.
Check if javac is recognized in VS Code internal terminal. If this check fails, try opening VS Code as administrator.
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.
Right click anywhere on the java file and select run code.
Check the output in the console.
Done, hope this helps.
Upvotes: 13