Android 是否支持 JDK 6 或 7

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20480090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:56:10  来源:igfitidea点击:

Does Android support JDK 6 or 7

androidjava-7jdk6

提问by user3084351

I am new to Android development. Can I use my existing Java code developed using JDK 7 in Android?

我是 Android 开发的新手。我可以在 Android 中使用使用 JDK 7 开发的现有 Java 代码吗?

The functions use xerces dom and xslt and xpathapi. Currently when I installed Android Eclipse ADT environment these functions are not compiling. I would also like to know whether an Android device itself supports JRE 6 or 7?

这些函数使用 xerces dom 和 xslt 以及 xpathapi。目前,当我安装 Android Eclipse ADT 环境时,这些功能无法编译。我还想知道 Android 设备本身是否支持 JRE 6 或 7?

回答by Mohamed El-Nakib

Originally Android development tools supported only jdk 6 features. But that was changed, first by Android Studio 0.3.2 in October 2013 see: http://tools.android.com/recent/androidstudio032released

原本Android开发工具只支持jdk 6特性。但这已经改变了,首先由 Android Studio 0.3.2 在 2013 年 10 月看到:http: //tools.android.com/recent/androidstudio032released

Support for language features like the diamond operator, multi-catch, try-with-resources, strings in switches, etc. When creating a new project, you can specify a source language level: enter image description hereNote that you can use all these language features not just with Android KitKat, but with older versions of Android too! There is one exception to that: try-with-resources, which will require minSdkVersion 19. Therefore, Studio will flag any uses in your code of try-with-resources if your minSdkVersion is less than 19:

支持菱形运算符、多捕获、try-with-resources、开关中的字符串等语言功能。在创建新项目时,您可以指定源语言级别: 在此处输入图片说明请注意,您不仅可以使用所有这些语言功能使用 Android KitKat,但也使用旧版本的 Android!有一个例外:try-with-resources,它需要 minSdkVersion 19。因此,如果您的 minSdkVersion 小于 19,Studio 将标记您的 try-with-resources 代码中的任何用途:

then by ADT plugin 22.6 in March 2014,see: http://developer.android.com/tools/sdk/eclipse-adt.html

然后在 2014 年 3 月通过 ADT 插件 22.6,参见:http: //developer.android.com/tools/sdk/eclipse-adt.html

Added support for Java 7 language features like multi-catch, try-with-resources, and the diamond operator. These features require version 19 or higher of the Build Tools. Try-with-resources requires minSdkVersion 19; the rest of the new language features require minSdkVersion 8 or higher. To use the new language features after installing ADT 22.6.0, ensure that you run Eclipse on JDK 7 and change your application project settings to use JDK 7.

添加了对 Java 7 语言功能的支持,例如 multi-catch、try-with-resources 和菱形运算符。这些功能需要版本 19 或更高版本的构建工具。Try-with-resources 需要 minSdkVersion 19;其余的新语言功能需要 minSdkVersion 8 或更高版本。要在安装 ADT 22.6.0 后使用新语言功能,请确保在 JDK 7 上运行 Eclipse 并将应用程序项目设置更改为使用 JDK 7。

Android is not intended to be 100% compatible with any Java SE API version, not 6 nor 8 nor any. this was the reason of the court case of Oracle raised Against Google, accusing Google of fragmenting Java. Some APIs are impossible to implement on android as Swing; Imagine a window with a close button on android ! Others were delayed but implemented : for e.g.: Charset class is in Java SE 1.4 but implemented in android API 9, AutoClosable in Java 7 implemented in Android API level 19 to allow implementation of try-with-resources language feature. Some APIs are existent but for different purpose as Console.

Android 不打算与任何 Java SE API 版本 100% 兼容,不是 6、8 或任何版本。这就是甲骨文公司提起对谷歌的诉讼,指控谷歌碎片化Java的原因。有些 API 不可能在 android 上实现为 Swing;想象一个在 android 上有一个关闭按钮的窗口!其他被延迟但已实现:例如:Charset 类在 Java SE 1.4 中实现,但在 android API 9 中实现,Java 7 中的 AutoClosable 在 Android API 级别 19 中实现,以允许实现 try-with-resources 语言功能。一些 API 是存在的,但与控制台的用途不同。

回答by blackpanther

Firstly, there is a difference between the Java JDK and the JRE. The JRE is the Java Runtime Environment while the JDK is the Java Development Kit. It is the JDK that you need for Android application development along with the existing Android SDK.

首先,Java JDK 和 JRE 之间存在差异。JRE 是 Java 运行时环境,而 JDK 是 Java 开发工具包。它是您开发 Android 应用程序所需的 JDK 以及现有的 Android SDK。

The Android SDK can use either JDK 6 or 7, however, it can ONLYuse the JDK 6 API.

Android SDK 可以使用 JDK 6 或 7,但是,它只能使用 JDK 6 API。

回答by Mina Fawzy

Yes , jdk 7 now support android Starting from build tools 19

是的,jdk 7 现在支持 android 从构建工具 19 开始

回答by Bruno Donath

JDK 5/6 ONLY. Actually andriod doesn't support jdk 6 completely because android jdk 6 is not Oracle JDK 6.

仅 JDK 5/6。实际上,andriod 并不完全支持 jdk 6,因为 android jdk 6 不是 Oracle JDK 6。

does android plan to support java 7

android是否计划支持java 7

Apace Harmony

天宇和谐