Compiling

.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 .class  files. These .class  files 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 java  command.

  • Example:

    • java -cp .;raylib.jar -Djava.library.path=lib Main

.jar

  • A .jar  file is a Java ARchive, essentially a packaged file that can contain:

    • Compiled Java classes ( .class  files)

    • 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 .zip  file but specifically for Java programs.

  • Key uses of .jar  files:

    • Library JARs

    • Contains reusable classes you include in your project.

    • Example : raylib.jar  contains 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.