.java
-
It's a Java source file.
-
Itβs a plain text file where you write Java code that follows the Java programming language syntax.
javac
-
It's the Java compiler.
-
Its job is to take your Java source code (files ending in
.java) and compile it into Java bytecode, which is stored in.classfiles. These.classfiles are what the Java Virtual Machine (JVM) executes. -
Example:
-
javac -cp raylib.jar Main.java
-
.class
file
-
It's the compiled Java bytecode.
-
You donβt run it directly; you run it through the Java Virtual Machine (JVM) using the
javacommand. -
Example:
-
java -cp .;raylib.jar -Djava.library.path=lib Main
-
.jar
-
A
.jarfile is a Java ARchive, essentially a packaged file that can contain:-
Compiled Java classes (
.classfiles) -
Libraries that your program depends on
-
Resources like images, sounds, or text files
-
A manifest that can specify which class has the main method
-
-
Itβs similar to a
.zipfile but specifically for Java programs. -
Key uses of
.jarfiles:-
Library JARs
-
Contains reusable classes you include in your project.
-
Example :
raylib.jarcontains the Java wrapper classes for Raylib. -
You include it in compilation/run commands using
-cp(classpath).
-
-
Executable JARs
-
Can run directly if it has a Main-Class in the manifest:
-
java -jar my_program.jar
-
-
Distribution
-
JARs make it easy to bundle a whole Java program and share it.
-