Home Deck, Away Deck: Training a Card Classifier in Java with JobRunr
with Ronald DehuysserRonald Dehuysser, creator of JobRunr, and I trained an image classifier for 20 Java trading cards without leaving Java. Training ran as a JobRunr background job and recognition was a plain synchronous call. That split worked. The model only half did, because it had learned one deck in one room and was tested on another.

YouTube
Home Deck, Away Deck: Training a Card Classifier in Java with JobRunr
Load YouTube video
This video is embedded from YouTube and will only be loaded after your consent. When loading it, personal data may be transmitted to YouTube or Google and cookies may be set.
More details are available in the privacy policy.
Project Source
Working Repository
Explore prompts, instructions, and examples used in the live modernization workflow.
Open repositorySession Timeline
- 00:00Introduction
- 02:38Why Ronald built JobRunr
- 07:02From AlexNet to our card classifier plan
- 12:38The repo, 20 cards and real webcam images
- 19:04Clearing the code for live coding
- 29:29Letting an AI agent write the preparation job
- 45:10Jobs, job context and retries in JobRunr
- 48:48Background job servers and scaling on Kubernetes
- 54:39Carbon-aware job scheduling
- 01:00:04Switching to the finished code and fixing the build
- 01:09:10Starting the prepare and training jobs
- 01:13:09JobRunr vs Temporal and the H2 database
- 01:22:14Database tables, performance and JobRunr Pro
- 01:29:00How the training job works with DJL and ResNet 18
- 01:36:50Live card recognition test
- 01:46:57Switching to Postgres
- 01:53:27Hibernate talk and wrap-up
Training a model takes minutes. Recognizing a card takes one call. If your Java app treats both the same way, a user ends up waiting for a training run. This session was about splitting the two. We put the slow part into a JobRunr background job and kept the fast part synchronous, all in Java.
The deck
For this session I made 20 original trading cards about the Java world, in the style of Top Trumps. The deck runs from Duke and JobRunr to the Garbage Collector, NullPointerException and a Legacy Monolith. The goal was simple: hold a card up to the webcam, and the app names it.

Ronald took the training pictures himself. He held each card up to his webcam and pressed a button 20 to 30 times per card. Keep that detail in mind. It decides how the story ends.
Two speeds of work
The app has two jobs, and they run at very different speeds.
Training is slow. A prepare job splits the photos roughly 80/20 into training and validation sets and crops them to a card-shaped frame. A train job then runs the epochs and reports accuracy and loss at the end. On stream, training took about 24 minutes. On Ronald's machine it had taken about 10.
Recognition is fast. One webcam frame goes into the trained model and a card name comes out. That stays a plain synchronous call. No job, no queue, no waiting.
JobRunr takes the slow part off the web request. The request returns right away, and the dashboard shows the job's logs and a progress bar. That bar is not magic, though.
The progress, you must maintain yourself, because JobRunr doesn't know how long it will last or what's even being done in there.
So the training code reports its own progress through the job context. In return you get a live view of a 24-minute job instead of a hanging browser tab.
Transfer learning without leaving Java
Nobody trained a neural network from scratch. DJL, the Deep Java Library, downloads ResNet 18, a pretrained image model with 18 layers. We only trained a small classification head on top of it for our 20 cards. That head lands in its own file, head.jd, next to the unchanged stock model.
Ronald picked ResNet 18 over ResNet 50 because it runs on lower-end hardware. DJL embeds the PyTorch C library through JNI behind a Java API. No Python, no extra service. Ronald mentioned Qwen vision as an alternative, but fine-tuning it would have meant leaving Java.
For a Java developer without an ML background, that is the useful part. You need a pretrained model, a few hundred photos and a job runner, not a new tech stack.
What JobRunr adds around the job
While the model trained, Ronald walked through what JobRunr does beyond running a method in the background.
- Retries: a failed job is retried 10 times with exponential back-off by default. The
@Jobannotation sets the name, retries, labels and job filters. - Background servers: one property turns an instance into a background job server. Deploy the same jar twice, and a hidden instance does the heavy work while the web-facing one stays fast. On Black Friday, Ronald said, KEDA can scale up extra pods.
- Shared databases: apps that share one database need separate table prefixes. Otherwise a server picks up jobs whose classes it doesn't have.
- Load: stress tests reach about 5,000 jobs per second on Postgres, MariaDB and MongoDB. One company runs 8 billion jobs a year on it.
I asked how JobRunr compares to Temporal, which I had tried in an earlier session with Les Jackson. Temporal is language-agnostic. JobRunr lives inside your application. If the JVM dies, the jobs stop too, but Kubernetes restarts the pod and JobRunr picks up where it left off.
Here you don't need to ask your infrastructure team, hey, can I install Temporal? Because Temporal is again an extra piece of infrastructure that you need to manage and sometimes even hire people for.
The most surprising feature was carbon-aware scheduling. You give a job a time window, and JobRunr runs it when the grid's carbon intensity is lowest. Ronald said his team's analysis found carbon emissions and electricity price correlated in 99.9% of cases.
Home deck, away deck
Then came the webcam test. My first card was recognized. After that, most answers were wrong or jumped between cards, on my machine and on Ronald's. The Legacy Monolith scored 68% on my side and 100% on his.

When it hit, it hit with confidence: XDEV at 99.9%. The trouble was how rarely that happened.
The model had learned the home deck: Ronald's printed cards, in Ronald's room, under Ronald's light. It then played an away game with my prints, my room and my light. We listed possible causes on stream, none of them tested:
- a different room and different lighting
- my printed cards looking different from Ronald's
- many cards sharing similar colors, such as the blue ones
- only about 30 photos per card
The pipeline did its job. The training data was too narrow. Ronald's fix is to generate more varied images and retrain. We did not retrain on stream.
What else went wrong
The plan was to delete the finished code and rebuild it with an AI agent. That did not work. The first agent kept asking the same question and deleted one class. Sonnet then wrote the preparation method, but also moved and deleted files I hadn't asked about. At about the one-hour mark we switched to the finished code on the main branch. I would rather explain working code than watch an LLM write the rest.
Final thought
Slow work belongs in a job. Training ran for 24 minutes in a JobRunr background job, with progress and logs in the dashboard. Recognition stayed a synchronous call. DJL kept the whole thing in Java. That split held up on stream, even when the model didn't.
If you build something like this, start with a pretrained model and wrap the training in a job. Then test with a deck from a different room before you trust the accuracy number.
Useful links
- JobRunr, the background job library for Java
- JobRunr on GitHub, the open source core
- JobRunr logging and job progress, how a job drives its own progress bar
- JobRunr carbon-aware jobs, scheduling within a time window at the lowest carbon intensity
- JobRunr Pro, the paid version with priority queues, workflows and job search
- DJL transfer learning tutorial, the same idea with a pretrained ResNet and the PyTorch engine
- Deep Residual Learning for Image Recognition, the paper behind ResNet
- My Temporal session with Les Jackson, durable workflows with the language-agnostic alternative we compared against
- Hangfire, the .NET library that first gave Ronald the idea for JobRunr
Comments
Load comments from GitHub optionally
The comment section is provided via Giscus and GitHub Discussions. It will only be loaded after your explicit consent. When loading it, personal data such as your IP address and technical metadata may be transmitted to GitHub, and cookies or similar technologies may be set.
Please confirm first before loading the comment section.
