Subject: Issue with jshell command alpine 3.20 with openjdk17

From: "Mittal,Gaurav" <[email-masked]>
Date: Tue, 18 Jun 2024 14:18:05 +0000

We are having issue when we run the jshell command and trying to compile and run java on Docker 3.20 with openjdk17 and get the below issue,

/ # jshell
Jun 18, 2024 1:39:15 PM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
error listing module locations for SYSTEM_MODULES: java.io.IOException: can't find system classes
Fatal Error: Unable to find package java.lang in classpath or bootclasspath
Exception in thread "main" java.lang.InternalError: Exception during analyze - com.sun.tools.javac.util.FatalError: Fatal Error: Unable to find package java.lang in classpath or bootclasspath
        at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.analyze(TaskFactory.java:393)
        at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.<init>(TaskFactory.java:384)
        at jdk.jshell/jdk.jshell.TaskFactory.lambda$analyze$1(TaskFactory.java:177)
        at jdk.jshell/jdk.jshell.TaskFactory.lambda$runTask$4(TaskFactory.java:212)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskPool.getTask(JavacTaskPool.java:193)
        at jdk.jshell/jdk.jshell.TaskFactory.runTask(TaskFactory.java:205)
        at jdk.jshell/jdk.jshell.TaskFactory.analyze(TaskFactory.java:174)
        at jdk.jshell/jdk.jshell.TaskFactory.analyze(TaskFactory.java:160)
        at jdk.jshell/jdk.jshell.Eval.compileAndLoad(Eval.java:1010)
        at jdk.jshell/jdk.jshell.Eval.declare(Eval.java:890)
        at jdk.jshell/jdk.jshell.Eval.eval(Eval.java:137)
        at jdk.jshell/jdk.jshell.JShell.eval(JShell.java:493)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSource(JShellTool.java:3618)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(JShellTool.java:1342)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processInput(JShellTool.java:1240)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1211)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.startUpRun(JShellTool.java:1172)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.resetState(JShellTool.java:1119)
        at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:945)
        at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:261)
        at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)
Caused by: java.lang.IllegalStateException: com.sun.tools.javac.util.FatalError: Fatal Error: Unable to find package java.lang in classpath or bootclasspath
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:383)
        at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.analyze(TaskFactory.java:390)
        ... 20 more
Caused by: com.sun.tools.javac.util.FatalError: Fatal Error: Unable to find package java.lang in classpath or bootclasspath
        at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.resolveImports(TypeEnter.java:360)
        at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.lambda$ensureImportsChecked$0(TypeEnter.java:174)
        at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.finishImports(TypeEnter.java:226)
        at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.ensureImportsChecked(TypeEnter.java:174)
        at jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:627)
        at jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:587)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1042)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.enter(JavacTaskImpl.java:345)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:399)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$analyze$1(JavacTaskImpl.java:379)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:379)
        ... 21 more
/ #
/ # cat <<EOF > HelloWorld.java
> public class HelloWorld{
>   public static void main(String a[]){
>     System.out.println("Hello helo!");
>   }
> }
> EOF
/ # /usr/bin/javac HelloWorld.java
error: not a file: HelloWorld.java
Usage: javac <options> <source files>
use --help for a list of possible options

If you are not the intended recipient of this message (including attachments) or if you have received this message in error, immediately notify us and delete it and any attachments.

If you do not wish to receive any email messages from Edward Jones, excluding administrative communications, please email this request to [email-masked]<mailto:[email-masked]> from the email address you wish to unsubscribe.

For important additional information related to this email, visit www.edwardjones.com/disclosures/email.html.<http://www.edwardjones.com/disclosures/email.html> Edward D. Jones & Co., L.P. d/b/a Edward Jones, 12555 Manchester Road, St. Louis, MO 63131 (c) Edward Jones. All rights reserved.