Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

JVM question?

  1. Nov 15, 2007 #1
    Okay this migh sound like a stupid question but I had to ask it.

    In the interest in time and energy I was considering the possibility of programming my 8051 for 2 projects for 2 classes using JVM. Mainly because my Microcontrollers class has failed to teach me much. I see that there is a few out there thought the much googled One Eighty Software seems to disapeard I was thinking JStick. I've never actually programmed a complex program on a microcontroller... the most was scrolling text of the national anthem. lol. I know that C/C++ is common but my second project is a group project and I'm the only one who knows anything a bout C, since I only took one class in it and the other 3 programming classes were in Java so it's what I'm most comfortable with not being a CS person. which you can probably tell from my rocky wording.

    The question is really basic, what are the limitations of using a JVM on a microcontroller, is the code. does it really follow the 'compile it once, run it anywhere' motto Sun beams about. no pun intended.

    Oh the program I'm writing is really quite simple it's just for basic user inputs for a automated coffemaker that is my senior project. The group project is inventory detection and user selection programs for a Vending machine... yes I have an unhealthy obsession with appliances.

    thnx in advance
     
  2. jcsd
  3. Nov 15, 2007 #2

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    Can you fit a JVM into an 8051? Even if had the processing power/memory it doesn't have a MMU which would make the impementation 'interesting'.
    Although there have been implementations of a JVM into an FPGA.
     
  4. Nov 16, 2007 #3
    This is probably what you want to look at, I guess. There is a special version of Java called "J2ME" for the embedded environment. But it's a bit confusing since they've named J2ME to "Java ME" at some point, and the website seems to act as if it will never be used for anything but cellular phones. This page seems to list the different Java Me implementations you can use, and it appears some of them require as little as 128k of memory... although I'm unsure which of the implementations listed there are available to the public, and I don't see a specific explanation of which microcontrollers are allowed to use.

    However, to be quite honest... you seem to be saying that you are only planning on this because no one else in the group has any programming skills, and you are more comfortable with Java than C? The thing is, I have very heavy suspicions that if it is even possible to get any of the Java VMs running on an 8501 (I'm not familiar with the 8501 but various google searches like "java vm 8501 embedded" turn up nothing), it will actually require more C skills to get whatever VM you find running on the 8501, than it would require to just write the coffeemaker in C in the first place.
     
  5. Nov 16, 2007 #4

    ranger

    User Avatar
    Gold Member

    I'm not sure as to the exact limitations. But Java is a P-code language, which means that the code is complied into an intermediate form, then interpreted. This results in execution time that is about 10 times slower than complied languages (C is a complied language). The thing with complied languages is that the object code that they generate is specific for the machine architecture. When translated into executables, they tend to be faster than interpreted and p-code languages. Interpreted languages are about 100 times slower because the source has to be reinterpreted each time it is run.

    The 'compile once run anywhere' means that your code is portable to any architecture, assuming that a JVM exist for that architecture. JVM is like a wrapper around the real hardware. Therefore, when you code in java, you're not dealing directly with the ISA of the architecture you're working in, only when the (virtual) ISA of JVM. No direct hardware control! Is this a good thing for embedded systems? If there were a chip that was made to execute java code directly without need for JVM, that would mean some great performance enhancements. Then there is also that issue about objected oriented programs and poor locality.

    These factors have prevented me from using java for any real time applications. Have the people in your group learn C :tongue2:
     
  6. Nov 16, 2007 #5

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    A friend of mine in Cambridge started a company to develop java on a chip (Vulcan Machines). Unfortunately he died suddenly soon after the prototype was built and I believe the product and the company dissapeared.
     
  7. Dec 14, 2007 #6
    Thanks for all of this information. One of my professors suggested JStamp development kit. but for the future I know that I should just go and better my C skills.
     
  8. Dec 14, 2007 #7

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    C really is much more suitable for most embedded stuff - wher eyou often have to do a lot of 'bit-fiddling' being basically a high level assembler.
     
  9. Dec 14, 2007 #8
    Yea, I've really started to notice that. If I hadn't been on such a time constraint I think I've could've afforded to use C. but since I also had to construct the coffee maker and i've been having a lot of problems with my solenoid dispensing circuit i had to do what i could. which I think is the whole point my senior engineer project. i've learned a lot on this project about how i've still got a whole lote to learn.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: JVM question?
  1. CPU question (Replies: 6)

  2. Fortran question (Replies: 2)

  3. Fortran Question (Replies: 32)

  4. Randomization Question (Replies: 4)

Loading...