Yes. Let's say you have a file in a directory: "src/main/java/org/zsh/Main.java". The class is named Main and is in the package org.zsh in this case. If you compile it with "javac src/main/java/org/zsh/Main.java" it will generate a file named "src/main/java/org/zsh/Main.class". So, if you execute it the old way, you would do "java -cp src/main/java org.zsh.Main" which means "Please execute the class with a main() method that is called Main and found in the package org.zsh. The classpath where this class can be found is "src/main". If you execute it the new way, you don't need to compile with javac. So you only have "src/main/java/org/zsh/Main.java". And you will execute by doing "java src/main/java/org/zsh/Main.java" and that's it. Bottom line, indeed, the ".java" at the end tells that it's a java source file and not a compile class found in the classpath that you want to execute. On Mon, 5 Feb 2024 at 15:44, Bart Schaefer wrote: > On Mon, Feb 5, 2024 at 10:04 AM Henri Tremblay > wrote: > > > > Java now supports (since Java 10 I think) command lines like > > > > java Math.java > > > > It will then just compile and launch that java file. But zsh won't > autocomplete for that. It only wants a jar, class file or whatever. > > The issue is here in the _arguments setup for _java: > > '(-):class:_java_class -m main ${(kv)opt_args[(i)(-classpath|-cp)]}' \ > '*::args:= _normal' \ > && return 0 > > The (-) says that the first word after "java" must either be an option > (start with "-") or must be a class name. The completion stops there > unless working on the next word. > > How does "java" itself distinguish between a class name and a file > name? Just whether the string ends in ".java"? >