laitimes

Microsoft Visual Studio Code Java February Update released

IT House February 19 news, according to Microsoft MSDN release, Microsoft recently released visual Studio Code Java February update, this month brought a special edition of education. At the beginning of each year, when many schools start, Microsoft has made a series of improvements in unit testing, GUI project development, and Gradle project creation to provide students and teachers with a better Java development experience on Visual Studio Code.

Microsoft Visual Studio Code Java February Update released

Easily enable unit tests in the base Java project

Microsoft receives feedback from many students that when developing a simple Java project, they always have to manually add test framework JAR packages (such as JUnit) to the project, and Microsoft's Java plug-ins do not provide functionality to help them solve this often repetitive operation. To address this, Microsoft added a new "Start Unit Test" feature to the plugin so that if your project (assuming it's a basic project without a build tool) doesn't contain any test-related libraries, you can easily add JAR and enable unit testing in your project.

To use this feature, simply jump to the Testing view and select Enable Java Testing (as shown in the image below).

Microsoft Visual Studio Code Java February Update released

This feature will do two things for you:

Download test-related JAR packages (JUnit, JUnit Jupiter, TestNG) depending on your choice

Add the downloaded JAR to the project library folder

Here is a demonstration of the feature:

Microsoft Visual Studio Code Java February Update released

Once you've used the feature, you can start writing unit tests straight away! You can get this feature in the latest update of the Extension Pack for Java.

Extension Pack for Java

https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack

Better support for GUI projects (JavaFX, Swing, and AWT).

GUI-based Java application development is common in school computer courses. The most commonly used GUI frameworks are JavaFX, Swing, and AWT. In this blog, Microsoft will introduce some recent optimizations to these frameworks.

JavaFX

Users can now create JavaFX projects directly from the new features. To use this new feature, simply bring up the command panel (Ctrl+Shift+P) and run the command "Java: Create Java Project". From the drop-down list, select JavaFX. When selected, a Maven archetype-based JavaFX project will be created for you.

Microsoft Visual Studio Code Java February Update released

To run a JavaFX application, you can open the Maven view, expand hellofx > Plugins > javafx and run the Maven target: javafx:run.

Microsoft Visual Studio Code Java February Update released

Microsoft also realized that students might be using other build tools (Gradle) or not using build tools to develop JavaFX projects, so it provided complete JavaFX examples for all of these different scenarios. Find the latest JavaFX samples for Visual Studio Code in this sample library.

JavaFX sample

https://github.com/openjfx/samples/tree/master/IDE/VSCode

Abstract Window Toolkit (AWT)

AWT is another popular framework in Java GUI application development. However, the types in AWT are hidden by default when code completion is due to certain limitations, so you may notice that code completion does not prompt the AWT class when working with AWT applications. To enable code completion for AWT, you can open the Command Panel (Ctrl+Shift+P) and choose the command Java: Help Center. Go to the Student section and select Enable AWT Development. Note that this action updates the workspace-level settings, so make sure that the workspace is open in Visual Studio Code. Here is a demonstration of the feature:

Microsoft Visual Studio Code Java February Update released

When the setting is enabled, code completion works in AWT projects! You can use this basic sample code to test your AWT on Visual Studio Code.

This basic sample code

ttps://code.visualstudio.com/docs/java/java-gui#_develop-awt-applications

Swing

By default, the Java plug-in package supports Swing application development. You can develop any Swing application directly without additional setup. To find more Swing examples, you can visit the official Oracle documentation.

Official Oracle Documentation

https://docs.oracle.com/javase/tutorial/uiswing/examples/components/index.html

Related documentation

In addition to these feature updates, Microsoft has added a dedicated Java GUI application development article to the official Visual Studio Code documentation. Microsoft hopes this article will help students and educators easily get started with GUI development and setup projects.

Java GUI applications

https://code.visualstudio.com/docs/java/java-gui#_develop-awt-applications

A simpler Gradle project creation process?

In addition to unit testing and GUI applications, Microsoft is seeing Gradle becoming more popular among students and professional developers. As a result, Microsoft has added support for Gradle project creation to the Java project creation workflow. This feature will help you walk through a simple Gradle project in a few steps. To use this feature, simply bring up the Command Panel (Ctrl+Shift+P) and run Java: Create Java Project and select Gradle from the list. Currently, this feature supports both Groovy and Kotlin as your DSL. Note that this new feature requires you to install the Gradle for Java plugin separately (not currently included in the Java plugin package).

Gradle for Java plugin

https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-gradle

Microsoft Visual Studio Code Java February Update released

You can also call up this feature directly from the "Create Java Project" button in the Java Project view.

Microsoft Visual Studio Code Java February Update released

To use all of the new features above, download the latest version of the Extension Pack for Java.

Read on