Using JVM on 8051 Microcontrollers: Pros and Cons

  • Thread starter ENGRedcupcake
  • Start date
In summary: JVM. He's been working on it for a few years now and I'm sure he would love to share his work with you.In summary, the question is whether or not a JVM can be installed on an 8051 microcontroller, and the answer is that it depends on the implementation. If the code is compiled into an intermediate form and then interpreted, the execution time will be 10 times slower than when the code is compiled into an object form. However, if a JVM is available for the architecture, the code will be portable.
  • #1
ENGRedcupcake
22
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
  • #2
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.
 
  • #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.
 
  • #4
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
 
  • #5
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.
 
  • #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.
 
  • #7
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.
 
  • #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.
 

Related to Using JVM on 8051 Microcontrollers: Pros and Cons

1. What is a JVM and how does it work on an 8051 microcontroller?

A JVM (Java Virtual Machine) is a software that allows Java programs to run on any device, regardless of the underlying hardware or operating system. It works on an 8051 microcontroller by translating the Java code into machine code that the microcontroller can understand and execute.

2. What are the pros of using a JVM on 8051 microcontrollers?

One of the main pros of using a JVM on 8051 microcontrollers is the portability of Java programs. This means that the same program can run on different devices without the need for any modifications. Additionally, Java is a high-level language that is easy to learn and write, making it a popular choice for programming microcontrollers. The JVM also provides memory management and error handling, making the development process more efficient and reliable.

3. Are there any cons to using a JVM on 8051 microcontrollers?

While there are many benefits to using a JVM on 8051 microcontrollers, there are also some drawbacks to consider. The biggest con is the overhead that comes with using a JVM. The microcontroller has to spend extra resources on running the JVM, which can result in slower performance and increased power consumption. Additionally, not all features of Java may be supported on the microcontroller, limiting the capabilities of the program.

4. Can any 8051 microcontroller run a JVM?

No, not all 8051 microcontrollers are capable of running a JVM. The microcontroller needs to have enough memory and processing power to support the JVM and the Java programs. Therefore, it is important to check the specifications of the microcontroller before attempting to use a JVM on it.

5. Are there alternatives to using a JVM on 8051 microcontrollers?

Yes, there are other languages and frameworks that can be used to program 8051 microcontrollers. For example, C and Assembly are commonly used for low-level programming on microcontrollers. There are also specific frameworks, such as Arduino, that provide a simplified programming environment for microcontrollers. Ultimately, the choice of language or framework will depend on the specific project requirements and the programmer's preferences and skills.

Similar threads

  • Programming and Computer Science
Replies
21
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
4
Views
5K
  • Programming and Computer Science
Replies
29
Views
6K
Replies
2
Views
903
  • Electrical Engineering
Replies
2
Views
1K
  • Computing and Technology
Replies
4
Views
5K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
1
Views
9K
Back
Top