Does Android support JDK 6 or 7 [duplicate]
Asked Answered
G

4

57

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

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?

Grapery answered 9/12, 2013 at 20:28 Comment(3)
This might help you out: #8578941Seemaseeming
Thanks for the reply. That still does not answer my question.Grapery
While the question is marked duplicate, the answers at the other question (which itself is a duplicate) #14488182 or it's "original" #17637679 are not only not helpful, but also wrong. As pointed out in the most upvoted answer below, The diamond operator and many other features are supported now.Stetson
C
80

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

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 here Note 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:

then by ADT plugin 22.6 in March 2014,see: 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.

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.

Contestant answered 10/3, 2014 at 14:57 Comment(8)
Wow, maybe there's even some hope that it will support Java 8 features in a not-too-distant future.Mande
@SimonAndréForsberg I hope so.Contestant
While new ADT supports new language features, it does not say whether new APIs are supported (e.g. Phaser), which is what the question is asking.Harrison
@Harrison android is not intended to be 100% comaptible with any java SE version, not 6 nor nor 8 nor any. this was the reason of the case of oracle vs google. 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. Some APIs are existent but for different purpose as Console.Contestant
@MuhammadAnnaqeeb Exactly. Many have confused the two. This distinction I think would be very important to answering the original question.Harrison
@Harrison O.K. I added it to the original answerContestant
Android not shipping Swing has nothing to do with the Java language level, I think you're mixing up language level (which relates to syntax and byte code instructions) and the language library. The language library on Android was originally based on Apache Harmony; the omission of Swing (and other packages) is mostly due to it not making sense as Android ships its own UI kit. But again, this has nothing to do with versions of Java.Electroplate
It is recommended to use API level 16 (Supports Java 7, albiet with try-with-sources), however runs good in emulator in android studio/intellij idea xml views.Beseech
B
4

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.

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

Bauman answered 9/12, 2013 at 20:32 Comment(1)
Thanks for the reply. The android eclipse environment is not compiling my code developed under regular eclipse with jdk 6. I have included jdk 6 library in the java build path.Grapery
M
3

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

Mightily answered 3/5, 2015 at 15:22 Comment(0)
T
0

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

does android plan to support java 7

Apace Harmony

Tremolo answered 9/12, 2013 at 21:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.