java command
The command that starts a JVM and runs a program, given a class name, a JAR file with -jar, or a single source file.
In more detail
You pass the java command a class name without the .class extension, because you are naming a class for the JVM to find, not a file. With -jar it runs the main class named in a JAR manifest, which is how the course container starts the service. Given a .java file it compiles in memory and runs it, which is the single-file source-code launcher. The -version option prints the JVM version to standard error.
Examples
java Hellojava -versionjava -jar app.jarjava Hello.javaRelated terms
- JVM — The program that loads class files and runs their bytecode, turning hot code into native machine instructions while it runs.
- main method — The method the JVM calls first when it starts a program: public static void main(String[] args).
- single-file source-code launcher — The java command's ability to compile a single .java file in memory and run it at once, leaving no class file behind.
- JAR file — A zip archive holding compiled classes and resources, plus a manifest describing them, which the JVM can load directly.
- class path — The list of folders and JAR files the JVM and the compiler search to find classes.
Taught in
- The Virtual Machine, The Kit And The Runtime — Modern Java: Virtual Threads & High-Throughput Services
- Release Trains And Long Term Support — Modern Java: Virtual Threads & High-Throughput Services
- The Lifecycle Of A Java Program — Modern Java: Virtual Threads & High-Throughput Services
- Packaging Into A Container — Modern Java: Virtual Threads & High-Throughput Services
- Jars, Automatic Modules And Runtime Images — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep