Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JRuby Workshop at RubyConf Austria 2026

JRuby Workshop at RubyConf Austria 2026

Slides for the JRuby Workshop presented at RubyConf Austria 2026

Avatar for headius

headius

May 30, 2026

More Decks by headius

Other Decks in Programming

Transcript

  1. @headius headius.com Hello! • Charles Oliver Nutter ("headius") • Full-time

    JRuby dev since 2006 • Co-founder of Headius Enterprises • "The JRuby Company" • My fi rst time in Vienna! • Second time running a workshop!
  2. Agenda • Short introductory talk about JRuby • Workshop topics

    and experimentation • https://github.com/headius/tutorial.git • Of fi ce hours
  3. Workshop Topics • Getting started with JRuby • Simple Java/JVM

    integration • Packaging apps for redistribution • Glimmer for JRuby • JRuby on Rails • Building and contributing to JRuby
  4. @headius headius.com What is JRuby? • Ruby on the Java

    Virtual Machine • Ruby implementation fi rst, JVM language second • Many bene fi ts from JVM ecosystem • Ruby code should "just work" • Try your code, your library • If something doesn't work, let us know!
  5. @headius headius.com Ruby Compatibility • JRuby 10 (LTS) supports Ruby

    3.4 • Language and core specs: 98% passing • Pure-Ruby standard library shared with CRuby • JRuby support for most native stdlib • JRuby 10.1 supports Ruby 4.0 • Leading edge, more experimental changes
  6. @headius headius.com JVM Language • JRuby is a fi rst-class

    JVM language • Extensions are written in Java, not insecure C code • JVM can optimize Ruby code just like Java • JVM garbage collector is concurrent and ef fi cient • We write Java so you don't have to! • But you can if you want to! (or Scala, Clojure, Kotlin...)
  7. @headius headius.com JRuby Architecture Ruby (.rb) JIT Java Instructions (java

    bytecode) Ruby Instructions (IR) parse interpret interpreter interpret C1 compile native code better native code java bytecode interpreter execute C2 compile Java Virtual Machine JRuby Internals
  8. @headius headius.com A World of Libraries • JVM ecosystem has

    hundreds of thousands of libraries • Graphics, GUIs, servers, document formats, ML/AI/LLM • One of the largest collections in the dev world • All available to JRuby users! • Easy integration into Ruby apps and code • "Magic" to make Java APIs look like Ruby
  9. @headius headius.com Example: 3D Bar Chart with JFreeChart • Chart-generating

    library with multiple output formats • Easily used from JRuby • https://blog.headius.com/ 2025/05/3d-charts-and-more-with- jruby-and-jfreechart.html
  10. @headius headius.com Threads vs Ractors 0 1.5 3 4.5 6

    6x 3.7x 1.6x CRuby threads CRuby ractors JRuby threads
  11. @headius headius.com "JRuby is excellent. I don't even code for

    MRI anymore and don't miss it." - "G. Gibson" on JRuby's Matrix chat
  12. @headius headius.com Headius Enterprises • Expert support for your JRuby

    apps • New dev, migrations, upgrades • Bug prioritization, security SLAs • Help with your code under NDA • Optimizing Ruby libraries • Using JVM tools to improve perf • headius.com/welcome
  13. @headius headius.com Thank You! • Please get in touch! •

    @headius on socials • [email protected] • JRuby Matrix chat • headius.com/welcome • USERS.md
  14. Getting Started with JRuby • Install a Java Development Kit

    (JDK) • Install JRuby • Run script or IRB to verify
  15. Install a JDK • getting_started/install_jdk.md • Multiple choice! • JDK

    vendor? • JDK version? • What is a "JRE"? • Any JDK for Java 21+ will do
  16. Getting the JDK • Option 1: OS-speci fi c package

    installer • apt, yum, pkg, brew • Option 2: download package or archive • Recommendation: Eclipse Temurin (by IBM) • Least encumbered, most "vanilla" build of OpenJDK
  17. Verify JDK Installation • java -version • jshell is IRB

    for Java • java in PATH is fi ne • Recommend setting JAVA_HOME $ java -version openjdk version "25" 2025-09-16 LTS OpenJDK Runtime Environment Zulu25.28+85-CA (build 25+36-LTS) OpenJDK 64-Bit Server VM Zulu25.28+85-CA (build 25+36-LTS, mixed mode, sharing) $
  18. Install JRuby • getting_started/install_jruby.md • Option 1: Installer/switcher tools •

    ruby-install, ruby-build, rvm, mise, asdf, ... • Option 2: Download from jruby.org • tarballs, zips, Windows installer • Unpack and set PATH
  19. ruby-install $ ruby-install jruby >>> Updating jruby versions ... >>>

    Installing jruby 10.1.0.0 into /Users/headius/.rubies/jruby-10.1.0.0 ... >>> Downloading https://repo1.maven.org/maven2/org/jruby/jruby-dist/10.1.0.0/jruby- dist-10.1.0.0-bin.tar.gz into /Users/headius/src ... >>> Verifying jruby-dist-10.1.0.0-bin.tar.gz ... *** No md5 checksum for /Users/headius/src/jruby-dist-10.1.0.0-bin.tar.gz >>> Extracting jruby-dist-10.1.0.0-bin.tar.gz to /Users/headius/src/jruby-10.1.0.0 ... >>> Installing jruby 10.1.0.0 ... >>> Symlinking bin/ruby to bin/jruby ... >>> Successfully installed jruby 10.1.0.0 into /Users/headius/.rubies/jruby-10.1.0.0
  20. Verify JRuby Install • getting_started/verify_jruby.md • ruby -v • irb

    • Run a simple script • Try to bundle install your app or library
  21. Verify with IRB $ ruby -v jruby 10.1.0.0 (4.0.0) 2026-04-20

    32f988b78c OpenJDK 64-Bit Server VM 25+36-LTS on 25+36-LTS +indy +jit [arm64-darwin] $ irb irb(main):001> RUBY_ENGINE => "jruby" irb(main):002> RUBY_VERSION => "4.0.0" irb(main):003> RUBY_ENGINE_VERSION => "10.1.0.0" irb(main):004> java.lang.Runtime.runtime.available_processors => 10
  22. Simple Swing GUI • java_integration/swing.md • Try adding a second

    button • Try adding a JLabel with a simple .new("text")
  23. JConsole • java_integration/jconsole.md • JConsole provides a monitoring/management tool for

    JVM apps • Monitor memory/heap, CPU usage, threads, and other details • The "MBeans" tab provides JVM and app-speci fi c tools • Run JRuby with --manage for JRuby tools • Try starting jconsole and connecting to your JRuby app
  24. JDK Mission Control • "Enterprise-grade" pro fi ling for JVM-based

    applications • Method calls • Memory allocations • Thread contention • Based on "JDK Flight Recorder" output
  25. JDK Flight Recorder • Built-in low-overhead monitoring and pro fi

    ling for JVM • Less than 1% overhead for monitoring • Less than 2% overhead for basic pro fi ling • "Almost unnoticeable" • Enable at command line or let JDK Mission Control enable it
  26. Packaging and Deploying • JRuby applications can be deployed like

    Ruby • Whatever you use today probably works fi ne • The JVM world provides other ways to deploy apps • "Executable" Java Archive (JAR) fi les that need only a JDK • Web Application Archive (WAR) fi les to deploy on an app server
  27. Warbler • packaging_apps/warbler • JRuby's tool for packaging apps •

    Combine your app plus JRuby plus dependencies in a single fi le • Executable JAR or deployable WAR • Generate con fi g, tweak settings, and go
  28. Using Warbler • gem install warbler • mkdir config •

    warble config and tweak settings • warble jar
  29. [] warbler $ java -jar hello.jar WARNING: A restricted method

    in java.lang.System has been called WARNING: java.lang.System::load has been called by com.kenai.jffi.internal.StubLoader in an unnamed module (file:/var/folders/ 5n/y5_kd6x94rndnyjh4519bp2w0000gn/T/jruby15925531817024339324extract/jruby- core-10.0.5.0-complete.jar) WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module WARNING: Restricted methods will be blocked in a future release unless native access is enabled Hello, world! [] warbler $
  30. Embedding JRuby • JRuby also includes Java APIs for embedding

    into apps • Load JRuby, request a new instance, execute code • Used by large Java apps and plugins to leverage Ruby features
  31. JRuby on Rails • JRuby has supported Rails since 2006

    (Rails 1.x) • ActiveRecord is the only part that needs JRuby-speci fi c logic • Native adapters replaced with Java's JDBC API • The rest of Rails generally just works • Rails on JRuby can scale much better due to threads
  32. Bootstrapping JRoR • Rails 7.0-7.1: Just "rails new" • Rails

    7.2: Use "rails new --skip-bundle" and tweak Gem fi le • Rails 8.0-8.1 • Use template from workshop repo or https://jruby.org/rails/8.0.rb • Pass `--skip-kamal` due to an unsupported dependency
  33. Workshop Ideas • Generate app • Scaffold something basic and

    migrate DB • Run server... it works • Run console... it works too • What else?
  34. Building JRuby • Easiest Ruby to build by far •

    Install JDK • Clone https://github.com/jruby/jruby.git • Run ./mvnw • The cloned repository is now a fully-functional JRuby install!
  35. Codebase Structure • bin - startup scripts and installed Ruby

    binstubs • core/src/main/java - Java sources of JRuby core • core/src/main/ruby - Ruby sources of JRuby core • lib/jruby.jar - the built JRuby core jar • lib/ruby/stdlib - Ruby core stdlib • lib/ruby/gems/shared/gems - Ruby gem home • test and spec - many, many test suites