{"slug": "build-and-deploy-java-ai-agents-with-google-adk", "title": "Build and Deploy Java AI Agents with Google ADK", "summary": "A developer built and deployed a Java AI agent using the Google Agent Development Kit (ADK) on Debian 13. The agent, which provides time and weather information, was compiled with Java 25 and deployed to Google Cloud Run. The complete project is available in a sample repository.", "body_md": "Debian 13 “Trixie” provides a clean, stable base for Java agent development. On a\n\nworkstation, virtual machine, or cloud instance, you can compile Java projects, run\n\nlocal web servers, use the Google Agent Development Kit (ADK) Dev UI, and deploy an\n\nagent to Google Cloud Run.\n\nThis guide builds a small ADK agent with time and weather tools. The complete project\n\nis available in the\n\n[sample repository](https://github.com/xbill9/adk-hello-world-java).\n\nStart with a Debian 13 installation and a user account that can run `sudo`\n\n. Confirm\n\nthe operating-system version:\n\n```\n. /etc/os-release\nprintf '%s %s (%s)\\n' \"$NAME\" \"$VERSION_ID\" \"$VERSION_CODENAME\"\n```\n\nUpdate the package index and install the base development tools:\n\n```\nsudo apt-get update\nsudo apt-get install -y curl git maven unzip zip\n```\n\nThis project compiles with Java 25. One convenient way to install a matching JDK is\n\n[SDKMAN!](https://sdkman.io/install/):\n\n```\ncurl -s \"https://get.sdkman.io\" | bash\nsource \"$HOME/.sdkman/bin/sdkman-init.sh\"\nsdk list java\n```\n\nSelect an available Java 25 identifier from the list and install it (for example, `25-open`\n\n):\n\n```\nsdk install java 25-open\njava --version\nmvn --version\n```\n\nBoth commands should report Java 25, and Maven must be version 3.6.3 or newer. The\n\nbuild enforces this minimum Maven version.\n\nAdd Google's Debian package repository:\n\n```\nsudo apt-get install -y apt-transport-https ca-certificates gnupg\ncurl https://packages.cloud.google.com/apt/doc/apt-key.gpg \\\n  | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg\necho \"deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main\" \\\n  | sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list\nsudo apt-get update\nsudo apt-get install -y google-cloud-cli\n```\n\nVerify the installation:\n\n```\ngcloud version\n```\n\nThe Google Cloud CLI is required for Vertex AI authentication and Cloud Run\n\ndeployment. It is not required if you only run the agent locally with a Gemini API\n\nkey.\n\n```\ngit clone https://github.com/xbill9/adk-hello-world-java\ncd adk-hello-world-java\n```\n\nThe agent lives at\n\n`src/main/java/agents/multitool/MultiToolAgent.java`\n\n. Its public\n\n`ROOT_AGENT`\n\nfield lets the ADK Dev UI discover it:\n\n```\npublic static final BaseAgent ROOT_AGENT = initAgent();\n\npublic static BaseAgent initAgent() {\n  return LlmAgent.builder()\n      .name(\"multi_tool_agent\")\n      .model(\"gemini-2.5-flash\")\n      .description(\"Agent to answer questions about the time and weather in a city.\")\n      .tools(\n          FunctionTool.create(MultiToolAgent.class, \"getCurrentTime\"),\n          FunctionTool.create(MultiToolAgent.class, \"getWeather\"))\n      .build();\n}\n```\n\nThe tools return structured maps with a `status`\n\nand a human-readable `report`\n\n. The\n\ntime tool uses IANA time zones and includes aliases for cities such as San Francisco,\n\nBeijing, and Mumbai.\n\nThis sample uses **ADK for Java 1.7.0**, the latest release available from Maven\n\nCentral as of July 27, 2026. Both runtime dependencies use the same property so the\n\ncore library and Dev UI cannot drift to different versions:\n\n```\n<properties>\n  <google-adk.version>1.7.0</google-adk.version>\n</properties>\n\n<dependency>\n  <groupId>com.google.adk</groupId>\n  <artifactId>google-adk</artifactId>\n  <version>${google-adk.version}</version>\n</dependency>\n<dependency>\n  <groupId>com.google.adk</groupId>\n  <artifactId>google-adk-dev</artifactId>\n  <version>${google-adk.version}</version>\n</dependency>\n```\n\nRecent changes relevant to this project include:\n\n`VertexAiSessionService`\n\n.`gen_ai.usage.input_tokens`\n\n.`gemini-2.5-flash`\n\nfor a stable,\nbroadly available tutorial baseline.These are framework improvements; the sample does not reimplement them. Keeping the\n\nADK dependencies pinned to 1.7.0 is what brings them into the application.\n\nRun the setup script:\n\n```\n./init.sh\n```\n\nIt offers two modes:\n\n`~/gemini.key`\n\nwith user-only permissions.The selected mode is stored in `~/.adk-hello-world-java-auth`\n\n. Run `./init.sh`\n\nagain\n\nwhenever you want to switch modes. The launch scripts source `set_env.sh`\n\nautomatically, so you do not need to export the variables by hand.\n\nFor Vertex AI, your account and the Cloud Run service identity must have the required\n\nVertex AI permissions. Cloud Run uses its service identity at runtime rather than a\n\ndownloaded credential file.\n\nCompile the project and run its eight JUnit Jupiter tests:\n\n```\nmake build\nmake test\n```\n\nThe tests cover agent initialization, supported and unsupported cities, time-zone\n\naliases, and null input. Run Checkstyle separately:\n\n```\nmake lint\n```\n\nThe lint target fails when Google Java Style warnings are found, which makes it useful\n\nin local development and continuous integration.\n\n```\n./cli.sh\n```\n\nExample session:\n\n```\nYou > What is the current time in Tokyo?\nAgent > The current time in Tokyo is 08:24.\n\nYou > What is the weather in New York?\nAgent > The weather in New York is sunny with a temperature of 25 degrees Celsius\n        (77 degrees Fahrenheit).\n\nYou > quit\n```\n\nStart the local server:\n\n```\n./devui.sh\n```\n\nOpen [http://127.0.0.1:8080](http://127.0.0.1:8080) in your browser. ADK scans the Maven\n\noutput under `target/classes`\n\nand makes `multi_tool_agent`\n\navailable in the UI.\n\nThe `web.sh`\n\nscript is retained as an alias for `devui.sh`\n\n.\n\nADK 1.6 tightened WebSocket origin handling and warns when the Dev UI uses the `*`\n\nCORS default. That default is convenient for local development but should not be\n\ntreated as an access-control mechanism for a public deployment.\n\nCloud Run deployment uses Vertex AI rather than copying a local API key into the\n\nservice. If you selected API-key mode, run `./init.sh`\n\nagain and choose Vertex AI.\n\nThen deploy:\n\n```\n./cloudrun.sh\n```\n\nThe script runs one source deployment for the `adk-hello-world-java`\n\nservice in\n\n`us-central1`\n\n. Because the repository contains a Dockerfile, Cloud Run builds that\n\nDockerfile remotely; Docker does not need to be installed on the Debian system.\n\nThe container reads Cloud Run's `PORT`\n\nenvironment variable and starts the ADK web\n\nserver. When deployment completes, gcloud prints the service URL.\n\nThe deployment is private by default because the service includes the ADK Dev UI and\n\nAPI. Configure authenticated callers with Cloud Run IAM. For a disposable public\n\ndemonstration, replace `--no-allow-unauthenticated`\n\nwith `--allow-unauthenticated`\n\nin\n\n`cloudrun.sh`\n\n; do not rely on CORS as access control.\n\n```\n.\n├── .dockerignore\n├── .gcloudignore\n├── Dockerfile\n├── Makefile\n├── cli.sh\n├── cloudrun.sh\n├── devui.sh\n├── init.sh\n├── pom.xml\n├── set_env.sh\n└── src\n    ├── main/java/agents/multitool/MultiToolAgent.java\n    └── test/java/agents/multitool/MultiToolAgentTest.java\n```\n\nDebian Trixie provides everything needed to build and test a Java ADK agent locally.\n\nThis sample keeps local authentication explicit, verifies the tool logic with JUnit,\n\nenforces Java style with Checkstyle, and uses Vertex AI service identity when deployed\n\nto Cloud Run.", "url": "https://wpnews.pro/news/build-and-deploy-java-ai-agents-with-google-adk", "canonical_source": "https://dev.to/gde/build-and-deploy-java-ai-agents-with-google-adk-28oi", "published_at": "2026-07-27 19:24:51+00:00", "updated_at": "2026-07-27 20:01:05.474354+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-agents", "developer-tools", "ai-infrastructure"], "entities": ["Google", "Google Cloud Run", "Debian", "Java", "Maven", "SDKMAN!", "Vertex AI", "Gemini"], "alternates": {"html": "https://wpnews.pro/news/build-and-deploy-java-ai-agents-with-google-adk", "markdown": "https://wpnews.pro/news/build-and-deploy-java-ai-agents-with-google-adk.md", "text": "https://wpnews.pro/news/build-and-deploy-java-ai-agents-with-google-adk.txt", "jsonld": "https://wpnews.pro/news/build-and-deploy-java-ai-agents-with-google-adk.jsonld"}}