Microsoft Dev Blogs

VS Code Java中的JavaC支持发布!

thumbnail

Introduction

Visual Studio Code Java support now partially supports using Javac as the underlying compiler, thanks to collaboration between Red Hat and Microsoft. This change aims to ensure timely support for the latest Java features and make Java language support on VS Code more consistent with common build tools like Maven and Gradle.

Benefits of Using Javac

  • More compliant with Java specifications
  • Faster support for new Java versions in VS Code and Eclipse
  • Reduced maintenance burden on JDT and JDT-LS teams
  • Easier testing of preview features and unreleased Java versions

How to Enable Javac Support

  1. Install the latest pre-release version of "Language Support for Java by Red Hat" or "Extension Pack for Java".
  2. Set java.configuration.runtimes to point to your Java 23 installation directory in VS Code settings.
  3. Restart VS Code.

Current Status of Javac Support

  • Editing assistance
  • Diagnostics
  • Quick fixes/refactoring
  • Hover hints
  • Navigation
  • Indexing
  • Building and class file generation

Future Goals

  • Improving usability to match ECJ functionality
  • Eliminating noticeable performance drops compared to ECJ-based compilation/diagnostics
  • Benchmark testing for VS Code Java and JDT-LS
  • Enhancing the onboarding experience to enable Javac support
  • Integrating upstream contributions to the JDT for internal testing in Eclipse

Conclusion

Javac support in VS Code Java is a significant step towards faster support for new Java versions and minimizing compiler differences. Users are encouraged to try out this preview support and provide feedback to help improve the experience.

Resources