Using JVM on 8051 Microcontrollers: Pros and Cons

  • Thread starter Thread starter ENGRedcupcake
  • Start date Start date
AI Thread Summary
Using a JVM on an 8051 microcontroller presents significant challenges due to the architecture's limitations, particularly the lack of a Memory Management Unit (MMU). While Java offers the advantage of portability with the "compile once, run anywhere" concept, its performance on microcontrollers is hindered by the interpreted nature of Java, making it approximately ten times slower than compiled languages like C. The discussion highlights that implementing a Java Virtual Machine (JVM) on an 8051 may require more advanced C programming skills than simply coding the project directly in C. Alternatives like J2ME exist for embedded systems, but their applicability and availability for specific microcontrollers are unclear. The consensus suggests that improving C skills would be beneficial for embedded projects, as C allows for more direct hardware control and is better suited for real-time applications. The participant acknowledges the steep learning curve and the need for practical experience in programming and hardware integration.
ENGRedcupcake
Messages
22
Reaction score
0
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
 
Technology news on Phys.org
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.
 
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.
 
ENGRedcupcake said:
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.

thnx in advance

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 :-p
 
ranger said:
If there were a chip that was made to execute java code directly without need for JVM, that would mean some great performance enhancements.
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.
 
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.
 
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.
 
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.
 
Back
Top