6

Does Android work with JRE 7? I can't find any documentation on it..

Cody
  • 8,686
  • 18
  • 71
  • 126
  • 1
    @ProgrammerX That question is rather unrelated. The Android **SDK** uses JRE to run its tools, but Android itself does not use the JRE. – poke Nov 01 '11 at 22:13

3 Answers3

7

Android does not use the JRE... it uses its own runtime optimized for mobile applications, the Dalvik VM. however, it has most of the features of the JRE.

aleph_null
  • 5,766
  • 2
  • 24
  • 39
  • 6
    A downvote? Really? There's a zillion dollar lawsuit over Google saying that Android isn't Java, and this gets a down vote? – Will Hartung Nov 01 '11 at 22:01
  • I'm not the down voter, but I do want to say...it still uses the JRE, yes? so it needs to be compatible with it..yes? or is that incorrect? – Cody Nov 01 '11 at 22:10
  • 1
    @DoctorOreo No, that’s incorrect. Android uses the Java language and its syntax, but does not compile for the Java Runtime Environment. All the base libraries etc. are just identical because it’s simpler to migrate that way. If they wanted Android’s libraries could be completely different. – poke Nov 01 '11 at 22:12
  • 1
    indirectly it kinda does. To compile for the Dalvik VM you need to compile for the JVM and then dex your classes. So the answer is that it both does and doesn't use the JVM. :P – Savvas Dalkitsis Nov 01 '11 at 22:40
1

Android runtime is Dalvik, but I think the question is if you can use java libraries (.jar) compiled with Java 7 (for example if you use the new try with resources clause in your source code, will it works on Android app?).

In that case I have seen that you could use with Gradles: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Using-sourceCompatibility-1.7

... which says:

With Android KitKat (buildToolsVersion 19) you can use the diamond operator, multi-catch, strings in switches, try with resources, etc. To do this, add the following to your build file: *

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 19
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

Checking the Android API I see that is not fully compliant, the ForkJoinPool in the Android API doesn't exist but the Autoclosable does it (which is used in try with resources) but from api 19.

Carlos Verdes
  • 3,037
  • 22
  • 20
1

Android uses the Dalvik virtual machine.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
Phil
  • 3,375
  • 3
  • 30
  • 46