On July 30, 2026, SouJava Brasília hosted the ninth edition of SouJava Sessions, featuring Sebastião Gazola with the topic “Introduction to Machine Learning with Java, JBang & DJL”.
The session was especially interesting because it moved away from a common path: talking about Machine Learning only from the perspective of Python or large language models.
Gazola brought a practical approach, showing how Java can also be used to experiment with models, run inference, and bring Machine Learning closer to real applications.
Machine Learning is not only Python. And Artificial Intelligence is not only LLMs.
Java also has a place in Machine Learning
When people talk about Machine Learning, Python is usually the first language that comes to mind.
That makes sense. Python has a strong presence in research, academia, model experimentation, data science, and prototyping.
But the session brought another perspective: in many corporate scenarios, especially when the goal is to put something into production, Java remains extremely relevant.
The conversation did not present Java and Python as enemies. Quite the opposite. The idea was complementarity.
Python is very strong for studying and creating models. Java can be very strong for integration, execution, packaging, operation, and using these models inside enterprise applications.
This point matters because many Java developers still see AI and Machine Learning as something distant from their ecosystem. The session showed that it does not have to be that way.
Before the model, there is data
One of the first points covered was the difference between traditional programming and Machine Learning.
In traditional programming, we usually start with rules and data to produce an answer.
In Machine Learning, the logic changes. We work with data, examples, and expected answers to train a model. After that, the model is used to infer new answers.
This change may sound simple, but it completely changes where the biggest challenge is.
In many traditional systems, the main effort is in implementing the algorithm.
In Machine Learning, a big part of the effort is in collecting, organizing, labeling, and preparing the data.
This was one of the strongest points of the session: the challenge is not only “running a model”. The challenge is understanding the problem, preparing the right data, and training something that makes sense for that context.
Supervised, unsupervised, and reinforcement learning
The session also covered the main types of training.
In supervised learning, the data is labeled. The model learns from examples where we already know the expected answer. This applies to tasks such as identifying whether an image contains a dog or a cat, detecting spam, or predicting prices based on historical data.
In unsupervised learning, the data is not previously labeled. The model tries to identify patterns, groups, and relationships. This can be useful for customer segmentation, behavior analysis, or detecting unusual patterns.
Reinforcement learning appears when the model evolves based on interactions, rewards, adjustments, and continuous improvement cycles.
The most important point here was understanding that, in practice, these approaches can be combined. A real system may start with one approach, evolve with another, and be refined over time.
Machine Learning is rarely a magic button. It is a process.
JBang as a fast path for experimentation
One of the highlights of the session was the use of JBang.
JBang allows developers to run Java code in a simpler and more direct way, without necessarily creating the full structure of a traditional project.
This works very well for experiments.
When we are testing models, validating hypotheses, loading files, analyzing images, or quickly checking the behavior of a library, we do not always want to start a complete Spring Boot project.
With JBang, it is possible to create a Java file, declare dependencies, run the code, and evaluate the result in a more dynamic way.
This agility brings Java closer to a lab-style experience without leaving the Java ecosystem behind.
DJL: Deep Java Library
The other main protagonist of the session was DJL, the Deep Java Library.
Gazola presented DJL as a practical library for working with Machine Learning in Java, allowing developers to load models, define criteria, run inference, and integrate this flow into Java applications.
One interesting point is that DJL works as a layer over Machine Learning engines. Instead of reinventing everything, it connects to engines such as PyTorch, TensorFlow, and other options from the ecosystem.
In practice, the developer defines what needs to be done, configures criteria to choose a model, and uses the predictor to run inference.
This flow helps bring Machine Learning closer to the daily work of Java developers:
- define the type of task;
- select or load a model;
- prepare the input;
- run inference;
- interpret the result;
- integrate it into an application.
It is an interesting bridge between the world of models and the world of enterprise applications.
From Model Zoo to Predictor
During the presentation, Gazola explained important DJL concepts such as Criteria, Model Zoo, and Predictor.
Criteria helps define the characteristics of the model that will be used: task type, input, output, filters, desired neural network, and other parameters.
Model Zoo works as a repository of available models. Based on the defined criteria, DJL can find a suitable model for that task.
After the model is loaded, the Predictor is responsible for running the inference.
This flow makes the idea more concrete. It is not only theory about Machine Learning. It is Java loading a model, processing an input, and returning a result.
Object detection in practice
One of the examples presented was object detection using a YOLO model.
The idea was simple and visual: load an image, run the model, and identify objects found in it.
The result showed detected elements with confidence percentages, such as person, car, bench, and book.
This type of example is powerful because it takes Machine Learning out of the abstract field.
Instead of staying only with concepts, the session showed Java code executing a real computer vision task.
This opens many possibilities: image inspection, document screening, automatic file organization, visual analysis, content classification, and many other applications.
Classifying dogs and cats
Another example presented was image classification between dogs and cats.
Gazola showed a simple dataset with images used for training and then executed a classifier to organize mixed images into different folders.
The example also showed something important: models make mistakes.
When an image was classified incorrectly, the explanation was straightforward: the training was still shallow, the dataset was small, and the model needed more data or adjustments.
This is an essential lesson.
In Machine Learning, an error does not necessarily mean the approach does not work. It often means the model needs more data, better labels, fine-tuning, or a more appropriate training strategy.
Transfer Learning: adjust instead of starting from zero
The session also introduced the idea of Transfer Learning.
Training a model from scratch can be expensive, time-consuming, and demanding in terms of processing power.
That is why, in many cases, it makes more sense to start from an already trained model and adjust it for a specific need.
This fine-tuning allows us to reuse previous knowledge from the model and specialize it for a more restricted domain.
This idea is extremely relevant for enterprise applications.
Not every company needs to create a model from zero. Many times, the smarter path is to adapt something that already exists to solve a specific problem.
Machine Learning is not only LLMs
Maybe one of the most important parts of the conversation was the distinction between Machine Learning and LLMs.
Today, when many people talk about AI, they immediately think about language models, chatbots, text generation, and tools like ChatGPT.
But Artificial Intelligence is much bigger than that.
Specific Machine Learning models can solve well-defined problems with lower cost, lower resource consumption, and greater predictability.
For classifying documents, detecting objects, categorizing images, identifying patterns, or performing specific inference tasks, it does not always make sense to use an LLM.
Sometimes, using a large language model for everything is like using a cannon to kill a fly.
This reflection is very important in the current moment, where many companies want to use AI without properly evaluating cost, security, infrastructure, predictability, and solution fit.
DJL and LangChain4j solve different problems
During the Q&A, an interesting comparison appeared between DJL and LangChain4j.
The answer was direct: they are tools for different goals.
LangChain4j is much more connected to the LLM universe, applications with language models, agents, chatbots, RAG, and integrations with providers such as OpenAI, Anthropic, Gemini, or local models.
DJL, on the other hand, is more connected to the use of specific Machine Learning models, such as computer vision, classification, prediction, and other specialized tasks.
It is not a competition about which one is better. It is about choosing the right tool for the right problem.
The real work is defining the problem
Another strong point of the session was the discussion about document classification, résumés, industries, programming languages, inferred seniority, and other types of categorization.
This kind of problem shows that Machine Learning starts before the code.
Before training a model, we need to answer questions such as:
- what problem do I want to solve?
- what data do I have?
- is this data labeled?
- which categories make sense?
- what result do I expect from the model?
- how will I measure whether it is correct?
- how will I improve the model later?
This step of organizing data, concepts, metadata, and categories is just as important as the implementation.
Without good data, there is no good model.
Why this session mattered
SouJava Sessions #009 mattered because it brought a topic that many Java developers still see as distant.
Machine Learning often seems like a subject restricted to data scientists, researchers, or Python developers.
But the session showed another path: Java can be used to experiment, integrate, and put models to work inside real applications.
With JBang, experimentation becomes faster.
With DJL, access to Machine Learning models and engines becomes closer to the Java ecosystem.
And with a correct understanding of the problem, developers can choose between an LLM, a specific model, traditional automation, or a combination of these approaches.
Final thoughts
SouJava Sessions #009 showed that Machine Learning with Java does not need to be distant, heavy, or exclusively academic.
Sebastião Gazola brought a practical introduction, connecting fundamental concepts, modern tools, and executable examples.
The main message is simple: before following the hype, we need to understand the problem.
Not everything needs an LLM.
Not everything needs a huge model.
Not everything needs to be solved with the most expensive or most famous tool of the moment.
Sometimes, a specific model, well trained and well integrated into a Java application, can solve the problem better, cost less, and behave more predictably.
For Java developers, this is a huge opportunity: understanding AI beyond the hype and starting to explore Machine Learning as part of the backend, automation, analysis, and enterprise systems ecosystem.
Once again, SouJava Brasília fulfilled its role: creating space for practical knowledge, real exchange, and topics that help developers see new possibilities inside the Java universe.