2 Replies Latest reply on Oct 3, 2013 7:06 PM by bobstro

    The PPSS thread on Android, Java, JVM, DVM

    bobstro

      Continuing the discussion from the "Java" thread that's drifted away from the OP's problem, I've started this thread where we can expound about things that won't help the OP.

       

      Deesy58 wrote:

      Is it true that ALL Android devices have the Dalvik Virtual Machine (DVM) installed in order to run apps? 

       

      I'd be hestitant to say ALL, but most, yes. I suppose one could hack together something that didn't run DVM (perhaps just using the Linux underpinnings of the OS?) but that's best left as an exercise to the reader.

       

      Could the DVM also run Java byte-code?

       

      Well, there's this to consider: "... There is no Java Virtual Machine in the Android platform. Java byte code is not executed. Instead Java classes are compiled into Dalvik executables and run on Dalvik, a specialized virtual machine (VM) designed specifically for Android. Unlike Java VMs, which are stack machines, the Dalvik VM is a register-based architecture."

       

      So you can write Android programs in the Java language, but it's not going to run on a Sun/Oracle Java VM. Mind you, a lot of code can probably be written to execute in either.
      , but there are also dependency issues. I'm no big-time developer, but there would be two considerations:

       

      1. If Android features are required, there would presumably be dependencies on the Android SDK (FT's point).
      2. If Java features NOT supported on Android (AWT, Swing) are required, unsupported functions and the like, then it won't work without being modified to use the Android equivalents.

      Is it the case that none of the browsers available for the NOOK products has the ability to execute JavaScript?

       

      I think they support some Javascript, but many sites have moved completely off of Flash and to HTML5+CSS3, which probably are not fully supported by the stock browsers.

       

      Again, to emphasize: Javascript is not Java, which might be part of the OP's issue in the original thread.

       

        • Re: JAVA Revisited
          deesy58

          bobstro wrote:

          Continuing the discussion from the "Java" thread that's drifted away from the OP's problem, I've started this thread where we can expound about things that won't help the OP.

           

          Deesy58 wrote:

          Is it true that ALL Android devices have the Dalvik Virtual Machine (DVM) installed in order to run apps? 

           

          I'd be hestitant to say ALL, but most, yes. I suppose one could hack together something that didn't run DVM (perhaps just using the Linux underpinnings of the OS?) but that's best left as an exercise to the reader.

           

          Could the DVM also run Java byte-code?

           

          Well, there's this to consider: "... There is no Java Virtual Machine in the Android platform. Java byte code is not executed. Instead Java classes are compiled into Dalvik executables and run on Dalvik, a specialized virtual machine (VM) designed specifically for Android. Unlike Java VMs, which are stack machines, the Dalvik VM is a register-based architecture."

           

          So you can write Android programs in the Java language, but it's not going to run on a Sun/Oracle Java VM. Mind you, a lot of code can probably be written to execute in either.
          , but there are also dependency issues. I'm no big-time developer, but there would be two considerations:

           

          1. If Android features are required, there would presumably be dependencies on the Android SDK (FT's point).
          2. If Java features NOT supported on Android (AWT, Swing) are required, unsupported functions and the like, then it won't work without being modified to use the Android equivalents.

          Is it the case that none of the browsers available for the NOOK products has the ability to execute JavaScript?

           

          I think they support some Javascript, but many sites have moved completely off of Flash and to HTML5+CSS3, which probably are not fully supported by the stock browsers.

           

          Again, to emphasize: Javascript is not Java, which might be part of the OP's issue in the original thread.

           


          If not all Android devices have the ability to execute programs, how would they be at all useful?  Unless the Android device has the capability of compiling and linking binary code, like that produced by C and C++, how could it execute any applications at all?  Remember, an Operating System (OS) is not an application. 

           

          Hmm.  I believe that I already pointed out that the Android OS uses the Dalvik Virtual Machine, rather than the Java Virtual Machine, and I cited my sources for that information.  What has not been answered, however, is whether the DVM can execute Java byte-code.  The descriptions in the Wikipedia article can be interpreted either way (no pun intended), so it is still not clear whether Java applications presented by a gaming Web site could be executed by an Android device. 

           

          Whether a machine (bare metal or virtual) is a stack machine or a register-based machine makes no difference.  If the code is compiled properly, it will execute correctly. 

           

          "So you can write Android programs in the Java language, but it's not going to run on a Sun/Oracle Java VM."  Huh?  I guess I am missing your point because this makes no sense to me.  Sorry.  If I write a program in the Java language, why would it not run on a Sun/Oracle Java Virtual Machine? 

           

          Your #1: Yes.  But that's a big if.  The implication is that if no Android-specific extensions are included in the code, that it would run.  Is this not true?  I'm asking.  I do not know the answer. 

           

          Your #2:  The same response. 

           

          My understanding of the primary differences between Android and other versions of the Linux Operating System is that Android was designed especially for use on devices with touch screens like smart phones and tablets, rather than devices that use mice and keyboards for interfacing with the user. 

           

          Not sure I understand your next point.  As I understand it, Flash and Javascript are different animals.  Flash contains a scripting capability called "Actionscript," but is has a number of differences from Javascript.  HTML5 and CSS3 are still relatively new, so I expect it will take a while before they become integrated into some browsers. 

           

          It is still not clear whether a NOOK Tablet with any available browser is able to execute Javascript, which is executed by the browser, and not by a virtual machine. 

           

          In any event, it appears that, while the primary Web pages on the pogo.com Web site use Javascript, one must download some of the games in order to play them (Bejeweled, for example).  If the game must be downloaded, it could certainly be written in Java, and be executed by a JVM.  In fact, it probably is written in Java.  Isn't this correct?

           

           

           

            • Re: JAVA Revisited
              bobstro
              deesy58 wrote:
              Hmm.  I believe that I already pointed out that the Android OS uses the Dalvik Virtual Machine, rather than the Java Virtual Machine, and I cited my sources for that information. 
              I didn't say you didn't.

              What has not been answered, however, is whether the DVM can execute Java byte-code. 

               

              The descriptions in the Wikipedia article can be interpreted either way (no pun intended), so it is still not clear whether Java applications presented by a gaming Web site could be executed by an Android device. 

               

              Whether a machine (bare metal or virtual) is a stack machine or a register-based machine makes no difference.  If the code is compiled properly, it will execute correctly.

               

              No idea. Have you tried it? You seem fascinated by the idea, so you should probably try it yourself and gain some enlightenment.  I can drop a lot of Java source code into either development environment and have it compile, but that's not what you seem to be describing. In any full application, I'd expect there to be problems with dependencies, but that doesn't mean a contrived example wouldn't work. Let us know what you find out and post the details here.

               

              "So you can write Android programs in the Java language, but it's not going to run on a Sun/Oracle Java VM."  Huh?  I guess I am missing your point because this makes no sense to me.  Sorry.  If I write a program in the Java language, why would it not run on a Sun/Oracle Java Virtual Machine? 

               

              Dependencies. You could modify the source code and compile for the other environment if you wanted to port it. User interface dependencies (e.g. swing JDK widgets) are one example cited. Lack of mouse on an Android device and lack of touch input on a desktop are obvious potential problems.

               

              Your #1: Yes.  But that's a big if.  The implication is that if no Android-specific extensions are included in the code, that it would run.  Is this not true?  I'm asking.  I do not know the answer. 

               

              You could presumably write something that is pure java with no external dependencies and have it execute as an intellectual exercise, but if user interface is one of the areas where the two environments differ, an actual user might not be able to do anything useful with it.

               

              Your #2:  The same response. 

               

              Same answer.

               

              My understanding of the primary differences between Android and other versions of the Linux Operating System is that Android was designed especially for use on devices with touch screens like smart phones and tablets, rather than devices that use mice and keyboards for interfacing with the user. 

               

              Exactly. The Android SDK provides interfaces that expose Android device features (e.g. touch, phone) to the programmer as FT noted, just like Oracle's Foundation Classes expose desktop features (e.g. mouse) to the desktop app programmer. You have to code to the environment it will run on. That's not to say that you couldn't write code with conditional compilation directives and make one source file compile for both. Again, though, I think that's more of an intellectual exercise than something you'd want to do in practice. The good news is that you can develop for either environment using free software tools, so there's no reason you couldn't spend a pleasant afternoon or forty finding out for yourself.

               

              Not sure I understand your next point.  As I understand it, Flash and Javascript are different animals.  Flash contains a scripting capability called "Actionscript," but is has a number of differences from Javascript.  

               

              You asked if none of the Android browsers supported Javascript. I wrote "I think they support some Javascript, but many sites have moved completely off of Flash and to HTML5+CSS3, which probably are not fully supported by the stock browsers." So while some Android browsers may support Javascript, that same browser may not support other of technologies that sites moving off of Flash require (HTML5+CSS3), and possibly lack some Javascript features. The suite of Javascript+HTML5+CSS3 is the foundation on which a lot of the "flash-less" sites depend today. To run the popular browser-based apps today, you typically will need either Flash, or the alternate suite.

               

              HTML5 and CSS3 are still relatively new, so I expect it will take a while before they become integrated into some browsers.

               

              These technologies do work well on the current generation of Chrome, Firefox and other "big name" browsers on Android. That's why Google was so confident in dropping Flash support from Chrome. There are some annoying differences in capabilities between them, but this is nothing new in the world of Internet browsers.

               

              It is still not clear whether a NOOK Tablet with any available browser is able to execute Javascript, which is executed by the browser, and not by a virtual machine. 

               

              Not sure what you're getting at. Javascript works fine in many browsers on Android today, and can be used (along with HTML5 and CSS3) to develop "hybrid" apps, where the Android SDK specific features are used for device-specific capabiltiies, but device-independent "web" code handles the bulk of the application code. This provides some degree of device-independence for the coder, while still providing "native" app features that can be distributed through an app store. You can code the shell using Android SDK features, and have that single shell deliver a variety of apps in a window using that non-Android specific web suite.

               

              In any event, it appears that, while the primary Web pages on the pogo.com Web site use Javascript, one must download some of the games in order to play them (Bejeweled, for example).  If the game must be downloaded, it could certainly be written in Java, and be executed by a JVM.  In fact, it probably is written in Java.  Isn't this correct?

               

              With the pogo Android app installed, those games work. The same games appear to use Flash and/or Javascript+HTML5+CSS3 (I'm not sure across all their games) when run in the browser, so clearly something is different between what runs in the app or in the browser. I'm honestly not sure (and not all that interested.)

               

              I would be surprised if pogo went the 100% native Android (Java) app though, when using a hybrid approach would let them deliver an Android wrapper hybrid app in the Google Play Store that can simply execute device-independent Javascript+HTML5+CSS3 in a window to deliver their library of games. A similar wrapper app on Apple devices could deliver that same web code on Apple devices. I'm not privy to their EA's internal strategies, and don't feel like reverse engineering them tonight.

               

              You could certainly figure it out with some effort if you care to. You obviously are intrigued by all this, so please report back with your results so we can discuss them at length.