[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-03。"],[[["\u003cp\u003eCloud Run functions utilize a specific runtime environment, which includes the operating system, add-on packages, language support, and the Functions Framework library that is identified by the language version.\u003c/p\u003e\n"],["\u003cp\u003eYou can select a preferred Java runtime version for your Cloud Run function during deployment, with supported versions listed on the Runtime support page.\u003c/p\u003e\n"],["\u003cp\u003eWhen deploying via the Google Cloud CLI, you use the \u003ccode\u003e--runtime\u003c/code\u003e parameter to specify the Java runtime and the \u003ccode\u003e--entry-point\u003c/code\u003e flag for the fully qualified class name.\u003c/p\u003e\n"],["\u003cp\u003eYou can prepare a Java function either directly through the Google Cloud console or locally, and specify dependencies using Maven or Gradle.\u003c/p\u003e\n"],["\u003cp\u003eCertain environment variables are automatically set by the Java runtime for use within your Cloud Run function.\u003c/p\u003e\n"]]],[],null,["# The Java Runtime\n================\n\nOverview\n--------\n\nYour Cloud Run function runs in an environment consisting of an operating\nsystem version plus add-on packages, language support, and\nthe Functions Framework library that supports and invokes your function.\nThis environment is identified by the language version, and is known as the\nruntime.\n\nFor information about runtimes in general, and to learn which Ubuntu version\neach Java runtime uses, see the [Cloud Run functions execution\nenvironment](/functions/1stgendocs/concepts/execution-environment#java).\n\nSelect your runtime\n-------------------\n\nCloud Run functions supports several versions of Java, listed on the\n[Runtime support](/functions/1stgendocs/runtime-support#java) page. You can\nselect the preferred Ruby Java for your function during deployment. \n\n### gcloud\n\nIf you're using the Google Cloud CLI, specify the runtime\nby using the `--runtime` parameter. The `--entry-point` flag specifies the\nfully qualified class name (FQN). For example: \n\n```bash\ngcloud functions deploy NAME --no-gen2 --entry-point FQN --no-gen2 --runtime java17 --trigger-http\n```\n\nFor more deployment parameters, see [Deploy a Cloud Run function](/functions/1stgendocs/deploy#basics).\n\n### Console\n\nIf you're using the Google Cloud console, select the runtime when\nyou create and deploy your function. See the\n[Google Cloud console quickstart](/functions/1stgendocs/console-quickstart-1st-gen) for\ndetailed instructions.\n\nFunction preparation\n--------------------\n\nYou can prepare a function directly from the Google Cloud console or write it on\nyour local machine and upload it. To prepare your local machine for Java\ndevelopment, see [Setting Up a Java Development Environment](/java/docs/setup).\nThe library that invokes your function is the [Java Functions\nFramework](/functions/1stgendocs/functions-framework).\n\nTo get started with Java on Cloud Run functions, see the\n[Quickstart](/functions/1stgendocs/create-deploy-gcloud-1st-gen).\n\nSource code structure\n---------------------\n\nFor Cloud Run functions to find your function's definition, your\nsource code must follow a specific structure. See\n[Writing Cloud Run functions](/functions/1stgendocs/writing#structuring_source_code)\nfor more information.\n\nSpecifying dependencies\n-----------------------\n\nYou can specify dependencies for your function using [Maven](https://maven.apache.org/) or [Gradle](https://gradle.org/). For more information,\nsee [Specifying dependencies in\nJava](/functions/1stgendocs/writing/specifying-dependencies-java).\n\nEnvironment variables\n---------------------\n\nYour Java runtime automatically sets certain environment variables for your\nfunction to use as needed. For details, see [Using Environment\nVariables](/functions/1stgendocs/configuring/env-var).\n\nWhat's next\n-----------\n\n- [Learn how to use Java frameworks](/functions/1stgendocs/concepts/java-frameworks) that provide out-of-the-box support for writing Java Cloud Run functions.\n- [Learn how to use popular APIs and logging\n frameworks](/functions/1stgendocs/concepts/java-logging) to configure the logging behavior of Java Cloud Run functions.\n- [Learn about the other JVM languages](/functions/1stgendocs/concepts/jvm-langs) you can use to write Cloud Run functions: Kotlin, Groovy, and Scala."]]