How Developers Can Use Quarkus to Make AI-Infused Java Apps
Java has always been among the top programming languages used by developers worldwide.  In 2020, Oracle mentioned that it was being used by 90% of all Fortune 500 companies. While it may have lost some ground to Python and other modern programming languages, when it comes to popularity, it continues to dominate in terms of the number of developers associated with it. As per the ‘State of Developer Ecosystem Report 2024’ by JetBrains, 6,223,000 Java developers top the charts, with Python developers coming in second. Similarly, many enterprises likely have Java-powered applications running on their enterprise systems due to its reliability, rich ecosystem, and large community behind it. As Java developers look to harness AI capabilities, Quarkus, a modern Java framework, stands out as a powerful tool to facilitate the integration of AI, particularly large language models (LLMs), into their Java applications. Daniel Oh, senior principal developer advocate at Red Hat, discussed the technology at the Great International Developer Summit. AIM had an exclusive interaction with Oh to understand its benefits. Evolution of AI and the Challenge to Java Developers Oh described the journey of AI as a long one, spanning several decades. It started with artificial intelligence (AI), moved to machine learning (ML) and deep learning, which were utilised for tasks such as fraud detection in banking. And then came GenAI, which was capable of producing creative content, including text, code, images, and videos. He emphasised that even though OpenAI’s models stirred up the GenAI conversation, the journey of AI did not start there. This evolution presents a unique challenge for developers, particularly those working with traditional technologies such as Java. For many, the misconception is that integrating AI requires becoming an AI or data expert. However, Oh explains that developers don’t need to take on such specialised roles to work with AI. Quarkus, a modern Java framework, simplifies the process significantly. Quarkus for AI-Powered Java Applications Quarkus, known for its performance and productivity, was designed to help developers build microservices, serverless applications, and AI applications. One of its key strengths is simplifying the development process, allowing developers to focus on writing less code while improving productivity. With Quarkus’ integration of tools like LangChain4j, Java developers can communicate with LLMs and other AI models effortlessly. According to Oh, “Quarkus actually integrates LangChain4j as some kind of dependency library or some kind of module in Gradle projects,” making it an ideal framework for building AI-powered applications. By simply adding dependencies to the Quarkus project, developers can start building AI-infused applications without requiring in-depth knowledge of the AI models themselves. “You can easily create AI services, communicate with any AI models, as long as you have the right access or permission,” Oh adds. Quarkus’ straightforward integration with AI models is similar to how developers use RESTful APIs or gRPC endpoints to integrate databases, messaging brokers, and cloud environments. Developers don’t need to become AI experts, Oh stressed. Building an AI App With Quarkus To demonstrate the tech, he started with a basic Quarkus project and introduced LangChain4j, a Java-native library inspired by LangChain from the Python ecosystem. By adding this as a dependency, developers gain the ability to define AI services using simple annotations. For instance, Daniel created a chatbot by annotating an interface and defining methods that communicate with OpenAI’s API. He configured the model (GPT-4 or GPT-3.5) and parameters in the application properties, making it easy to switch models or tweak performance. Oh then demonstrated how Quarkus supports live coding and hot reloading through its dev mode, which enables developers to instantly see the effects of code changes without needing to restart the application. The integrated Dev UI offers a visual interface for interacting with endpoints and AI services. Oh also quickly created a new Java application tailored for AI integration using Quarkus project generator at quarkus.io. He selected AI-specific extensions such as OpenAI for large language model access and EasyRAG for enabling retrieval-augmented generation. He customised the project’s metadata, such as the artifact ID, to define the application’s identity and structure. Once the setup was complete, Daniel generated and downloaded the project as a ZIP file, unzipped it, and opened it in his IntelliJ IDEA IDE. The generated project included a pre-configured structure with sample documents (like PDFs and text files) placed in a designated folder. These were automatically ingested into a vector server. He then ran the application using the dev mode, activating Quarkus’s live coding mode and Dev UI. This provided him with immediate access to a visual interface, where he could test AI interactions, inspect logs, and view system messages in action—all without needing to restart or redeploy the application. Java or No Java? “Business leaders are probably just interested in two things. One is cost-saving, and then make more money,” Oh told AIM. He explains that if a company has existing Java applications, it should use tools like Quarkus rather than switching to another codebase just because it’s the trend. He believes that an organisation with Java developers at its disposal can save money if it continues using Java-based tech and adds AI integrations to it.
Java developers don’t need to be AI experts to integrate AI into their applications.
Java developers don’t need to be AI experts to integrate AI into their applications.
["Java"]
["GenAI", "machine learning", "artificial intelligence", "OpenAI", "AI", "ML", "RAG", "LangChain", "deep learning", "Aim", "Java"]
["AI", "artificial intelligence", "machine learning", "ML", "deep learning", "GenAI", "OpenAI", "LangChain", "Aim", "RAG"]
I am a tech aficionado and a computer science graduate with a keen interest in AI, Coding, Open Source, and Cloud. Have a tip? Reach out to ankush.das@aimmediahouse.com