Software > Software

java programming for microcontroller.

(1/3) > >>

please anybody tell me if we can program ATMega-32 micro-controller in JAVA.  if so which coder software can i use.


To my knowledge there are no widely used Java compilers for AVR uCs. To run JavaVM on a microcontroller is not very efficient (if possible at all) and to compile Java code to native machine code defeats the purpose of Java apps being portable. Why do You want to use Java anyway? Atmel provides very good development tools and resources for C.

HI newInRobotics,

Actually i have an experience of coding  AVR microcontroller in C, but now i am learning JAVA programming (especially for machine learning and computer vision task). As i want to build a complete embedded system (Robot), i wish to use Java programming for all purpose. java has got a rich classes for such purpose and an ease in mathematical calculations, so i thought can't i use java instead of C for programming AVR.     the other thing is can't i translate java coded program to C and then to hex for AVR?...  please help me in detail  because i am a beginner in JAVA and  might be asking silly questions..!!!

The biggest problem is that AVR chips don't have enough memory to put a JVM into, much less hold programs and data that typically come with a Java program.

You might look at some of the ARM processors, many of them are capable of running Linux, and would be able to suppoprt java to some extent.



may be this is the right thread to introduce HaikuVM.

HaikuVM at its core is just another JAVA VM for micros (I began with AVRs). The point here is, that I decided to go without building an own JAVA runtime. Instead HaikuVM is tailor made to use the leJOS runtime.

HaikuVM has been started to program my ARDUINO based robot in JAVA.
Yes, with HaikuVM you can program an ARDUINO with JAVA!

For those who ever wanted to let the LED of an ARDUINO blink in a parallel thread. This is how it works:

--- Code: ---package arduino.tutorial;

import static haiku.avr.lib.arduino.WProgram.*;

public class BlinkWithThread extends Thread {
    static byte ledPin = 13;            // LED connected to digital pin 13

    public void run()                   // run over and over again
        while (true) {
            digitalWrite(ledPin, HIGH); // sets the LED on
            delay(1000);                // waits for a second
            digitalWrite(ledPin, LOW);  // sets the LED off
            delay(1000);                // waits for a second

     * @param args
    public static void main(String[] args) {
        pinMode(ledPin, OUTPUT);        // sets the digital pin as output
        new BlinkWithThread().start();

--- End code ---

HaikuVM works by compiling JAVA bytecode to C code to be finally compiled by a C cross compiler for your target platform. So, the resulting code is small and fast.

Software which you need:

* JAVA 1.6
* WinAVR (C cross compiler for AVRs)
* HaikuVM
* Eclipse IDE (optional)

* Preemptive threads
* Exceptions
* Synchronization
* double and float support
* Arrays, including multidimensional ones
* Recursion
* Garbage collection
* Supports inheritance and interfaces
* Runs on AVR ATmega8, AVR ATmega328p (and Windows, UNIX)
* Configurable 64, 32 or 16 bit data types including half precision float
* Configurable 16 or 8 bit char type
* Tested with Suns JAVA 1.6
* Zero Assembler Code
* Requires only down to 5k Bytes of code memory (includes HaikuVM and your Java program)
* Needs only 250 Bytes RAM (the rest is for your JAVA application)
* About 55k Java opcodes per second on 8 Mhz AVR ATmega8


[0] Message Index

[#] Next page

Go to full version