Consider the following file hierarchy and content:
---module-info.java
module m {}
---test/Test.java
package test;
public class Test {
public static void main(String... args) {
System.err.println("Hello, world!");
}
}
---.vscode/settings.json
{}
---
This can be e.g. a result of opening the directory as a workspace in VS Code.
A packed version of the directory is also attached.
Then running this using the source file launcher fails:
---
$ ~/tools/jdk/jdk-22/bin/java test/Test.java
Exception in thread "main" java.lang.LayerInstantiationException: Invalid package name: /vscode for module: m
at java.base/java.lang.ModuleLayer.defineModules(ModuleLayer.java:699)
at jdk.compiler/com.sun.tools.javac.launcher.MemoryContext.newClassLoaderFor(MemoryContext.java:240)
at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.execute(SourceLauncher.java:202)
at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.run(SourceLauncher.java:153)
at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.main(SourceLauncher.java:78)
---
---module-info.java
module m {}
---test/Test.java
package test;
public class Test {
public static void main(String... args) {
System.err.println("Hello, world!");
}
}
---.vscode/settings.json
{}
---
This can be e.g. a result of opening the directory as a workspace in VS Code.
A packed version of the directory is also attached.
Then running this using the source file launcher fails:
---
$ ~/tools/jdk/jdk-22/bin/java test/Test.java
Exception in thread "main" java.lang.LayerInstantiationException: Invalid package name: /vscode for module: m
at java.base/java.lang.ModuleLayer.defineModules(ModuleLayer.java:699)
at jdk.compiler/com.sun.tools.javac.launcher.MemoryContext.newClassLoaderFor(MemoryContext.java:240)
at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.execute(SourceLauncher.java:202)
at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.run(SourceLauncher.java:153)
at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.main(SourceLauncher.java:78)
---