Getting Started with JVM FYI

Home Documentation

Getting Started with the JVM

Welcome to JVM FYI! This guide will help you understand the Java Virtual Machine ecosystem and get started with JVM languages and technologies.

What is the JVM?

The Java Virtual Machine (JVM) is a runtime environment that executes Java bytecode. It provides platform independence by abstracting the underlying operating system, allowing “write once, run anywhere” capability. The JVM has evolved into a powerful platform supporting multiple programming languages.

Key Features

  • Platform Independence: Run on any system with a JVM installed
  • Memory Management: Automatic garbage collection
  • Performance: Just-in-time (JIT) compilation for optimized execution
  • Security: Sandboxed execution environment
  • Multi-language Support: Host various programming languages
  • Mature Ecosystem: Extensive libraries and frameworks

JVM Languages

Java

The original and most widely used JVM language.

Characteristics:

  • Object-oriented, statically typed
  • Extensive standard library
  • Large community and ecosystem
  • Enterprise-ready frameworks

Scala

A functional and object-oriented language that compiles to JVM bytecode.

Characteristics:

  • Functional programming features
  • Strong type system with inference
  • Interoperable with Java
  • Concise, expressive syntax

Kotlin

A modern statically typed language, officially supported for Android.

Characteristics:

  • 100% interoperable with Java
  • Null safety built-in
  • Concise syntax
  • Coroutines for asynchronous programming

Clojure

A dynamic, functional Lisp dialect for the JVM.

Characteristics:

  • Functional programming paradigm
  • Immutable data structures
  • Powerful macro system
  • Excellent concurrency support

Other JVM Languages

  • Groovy: Dynamic language with Java-like syntax
  • JRuby: Ruby implementation on the JVM
  • Jython: Python implementation on the JVM
  • JVM.js: JavaScript engines on the JVM

Installing the JVM

Java Development Kit (JDK)

Option 1: Oracle JDK

# Download from oracle.com/java/technologies/downloads/

Option 2: OpenJDK (Recommended)

# macOS with Homebrew
brew install openjdk@21

# Ubuntu/Debian
sudo apt install openjdk-21-jdk

# Windows - download from adoptium.net

Option 3: SDKMAN (Multi-version management)

# Install SDKMAN
curl -s "https://get.sdkman.io" | bash

# Install latest Java
sdk install java

# Install specific versions
sdk install java 21.0.1-tem
sdk install java 17.0.9-tem
sdk install java 11.0.21-tem

# Switch versions
sdk use java 21.0.1-tem

Verify Installation

java -version
javac -version

Language-Specific Setup

Java

Already included with JDK installation.

Hello World:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, JVM FYI!");
    }
}

Scala

# Using SDKMAN
sdk install scala

# Using Homebrew (macOS)
brew install scala

# Using sbt (build tool)
sdk install sbt

Hello World:

object HelloWorld {
  def main(args: Array[String]): Unit = {
    println("Hello, JVM FYI!")
  }
}

Kotlin

# Using SDKMAN
sdk install kotlin

# Using Homebrew (macOS)
brew install kotlin

Hello World:

fun main() {
    println("Hello, JVM FYI!")
}

Clojure

# Using SDKMAN
sdk install clojure

# Using Homebrew (macOS)
brew install clojure/tools/clojure

Hello World:

(println "Hello, JVM FYI!")

Build Tools

Maven

Java’s most popular build tool.

# Install with SDKMAN
sdk install maven

# Create new project
mvn archetype:generate -DgroupId=com.example -DartifactId=my-app

Gradle

Modern build tool supporting multiple JVM languages.

# Install with SDKMAN
sdk install gradle

# Create new project
gradle init

sbt

Scala’s primary build tool.

# Install with SDKMAN
sdk install sbt

# Create new Scala project
sbt new scala/scala-seed.g8

Leiningen

Clojure’s primary build tool.

# Install with Homebrew
brew install leiningen

# Create new project
lein new app my-app

JVM Concepts

Bytecode

JVM languages compile to Java bytecode - platform-independent intermediate code.

# Compile Java to bytecode
javac HelloWorld.java

# View bytecode
javap -c HelloWorld

Memory Management

The JVM manages memory automatically through garbage collection.

Memory Areas:

  • Heap: Object storage
  • Stack: Method calls and local variables
  • Method Area: Class metadata
  • PC Register: Current instruction pointer

ClassLoader

Loads classes into the JVM at runtime, enabling dynamic loading and reflection.

JIT Compilation

Just-In-Time compiler optimizes bytecode to native machine code during execution.

Development Environments

IntelliJ IDEA

Premier IDE for JVM development.

  • Excellent support for Java, Scala, Kotlin
  • Built-in build tool integration
  • Advanced debugging and profiling

Eclipse

Popular open-source IDE.

  • Strong Java support
  • Plugin ecosystem
  • Free and widely used

VS Code

Lightweight editor with JVM extensions.

  • Java Extension Pack
  • Scala Metals extension
  • Kotlin extension

Command Line Tools

Many developers prefer terminal-based development.

# Compile and run Java
javac HelloWorld.java && java HelloWorld

# Scala REPL
scala

# Kotlin REPL
kotlinc-jvm

Next Steps

Explore these areas to deepen your JVM knowledge:

  1. JVM Languages - Deep dive into Java, Scala, Kotlin, Clojure
  2. Performance - JVM tuning, garbage collection, profiling
  3. Frameworks - Spring, Play, Ktor, Ring
  4. Build Tools - Maven, Gradle, sbt, Leiningen
  5. Best Practices - Code organization, testing, deployment

Web Development

  • Spring Boot (Java): Enterprise web applications
  • Play Framework (Scala): Reactive web framework
  • Ktor (Kotlin): Asynchronous web framework
  • Ring (Clojure): Composable web applications

Data Processing

  • Apache Spark: Large-scale data processing
  • Apache Kafka: Event streaming platform
  • Elasticsearch: Search and analytics engine
  • Apache Cassandra: Distributed database

Enterprise

  • Spring Framework: Comprehensive Java framework
  • Hibernate: Object-relational mapping
  • Apache Camel: Integration framework
  • Akka: Actor-based concurrent programming

Resources

Ready to dive deeper? Check out our comprehensive documentation for detailed guides covering all aspects of JVM development!