'VSCode support for Java Unnamed Packages

I'm a teacher with a lot of simple .java files to grade. The students have not and will not be using packages as this is a rather simple class.

Having one .java file runs fine. When a second one or more are added, VSCode compiles all the files in the folder. Needless to say, some student files may contain syntax errors. So I can't run or debug the one student file I'm grading.

Is there a workaround for this situation? It seems to be an option under Java specification.


7.4.2. Unnamed Packages states:

An implementation of the Java SE Platform must support at least one unnamed package. An implementation may support more than one unnamed package, but is not required to do so. Which ordinary compilation units are in each unnamed package is determined by the host system.



Solution 1:[1]

You can have a try on Code Runner. Then you can right-click and select Run Code or click the Run Code button on the top-right.

Update:

In fact, you can ignore the Build failed prompt and click Proceed to continue the Run Java or Debug Java actions.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1