There have been reports (e.g. [^1]) that in some runtime images java
cannot run source files. Here's another scenario.
If a source file is run by the java command from a jlink-built runtime
image that doesn't include jdk.compiler, the output will read:
./java X.java
Error: A JNI error has occurred, please check your installation
and try again
Exception in thread "main" java.lang.InternalError: Module
jdk.compiler not in boot Layer
at
java.base/sun.launcher.LauncherHelper.loadModuleMainClass(LauncherHelper.java:807)
at
java.base/sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:757)
I accept that the inability to run a source file is not exactly
unexpected in such circumstances. However, the usage output for the
java command suggests that this capability is __integral__:
Usage: java [java options...] <application> [application arguments...]
Where <application> is one of:
<mainclass> to execute the main method of a
compiled main class
-jar <jarfile>.jar to execute the main class of a JAR archive
-m <module>[/<mainclass>] to execute the main class of a module
<sourcefile>.java to compile and execute a source-file program
[1]:
https://mail.openjdk.org/archives/list/[email protected]/thread/ZESK4FDJDWPPRNDETXJMSPISJ6RY52W7/#LCPBHUYGJCS3TD5ZHV4K6ISI326XPG23