LinuxCommandLibrary

java

Java application launcher and runtime

TLDR

Run class file

$ java [ClassName]
copy
Run JAR file
$ java -jar [application.jar]
copy
Run with classpath
$ java -cp [path/to/classes] [ClassName]
copy
Set heap size
$ java -Xmx[512m] -jar [app.jar]
copy
Run with system property
$ java -D[property=value] [ClassName]
copy
Show version
$ java -version
copy
Run single source file
$ java [Source.java]
copy

SYNOPSIS

java [options] class [args...]
java [options] -jar jarfile [args...]

DESCRIPTION

java launches Java applications by loading and executing compiled bytecode in the Java Virtual Machine (JVM). It can run individual class files, JAR archives, or since Java 11, single source files directly.
The runtime handles memory management through garbage collection, threading, and platform abstraction. JVM options control heap size, garbage collector behavior, and system properties. The classpath mechanism locates dependencies, while the module path (Java 9+) provides stronger encapsulation.

PARAMETERS

CLASS

Main class to execute.
-jar FILE
Execute JAR file.
-cp PATH
Class path for dependencies.
-Xmx SIZE
Maximum heap size.
-Xms SIZE
Initial heap size.
-D PROP=VAL
Set system property.
-version
Show version information.
--help
Display help information.

CONFIGURATION

JAVA_HOME

Environment variable pointing to the JDK installation directory.
CLASSPATH
Environment variable specifying default class search paths.
JAVA_TOOL_OPTIONS
Environment variable for default JVM options applied to all Java invocations.
_JAVA_OPTIONS
Environment variable for JVM options (vendor-specific, overrides JAVATOOLOPTIONS).

CAVEATS

Requires JRE/JDK. Version compatibility matters. Memory settings may need tuning.

HISTORY

Java was created by James Gosling at Sun Microsystems in 1995. It's now maintained by Oracle and the OpenJDK community.

SEE ALSO

javac(1), jar(1), jps(1), jstack(1)

> TERMINAL_GEAR

Curated for the Linux community

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

$1,589.00
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

$54.00
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

$239.99
Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

$169.99
KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

$16.99