About Question enthuware.ocpjp.i.v11.2.1258 :
Posted: Mon Nov 30, 2020 2:21 pm
Hi,
it seems there is a mistake. Correct option is "None of the above.", because it is throws the exception.
java version:
Without extension.
Also tried to rename from MyClass.java to MyClass - it didn't help. Java source class must have .java extension and it must be specifed in the command.
Filename extension is required when running single file source code.
Thanks.
it seems there is a mistake. Correct option is "None of the above.", because it is throws the exception.
Code: Select all
public class MyClass
{
public static void main(String[] args)
{
System.out.println(args[0]);
}
}
Code: Select all
C:\1\projects\sandbox-java\sandbox-java11-cmdline>java -version
java version "11.0.9" 2020-10-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.9+7-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.9+7-LTS, mixed mode)
Code: Select all
C:\1\projects\sandbox-java\sandbox-java11-cmdline>java MyClass hi
Error: Could not find or load main class MyClass
Caused by: java.lang.ClassNotFoundException: MyClass
Filename extension is required when running single file source code.
Code: Select all
C:\1\projects\sandbox-java\sandbox-java11-cmdline>java MyClass.java hi
hi