Go Down

Topic: Java on Arduino (Read 1 time) previous topic - next topic

Brian Neltner

I've seen some posts saying that this is not implemented in any way, but they are old so I figured I'd inquire again in case this has changed.

I want to build a neat toolkit based on Arduino for use in AP Computer Science classrooms. It seems like a fantastic fit -- low cost, large community, and kids get to make things in the real world do cool stuff with a minimum of programming skill.

Trick is, APCS courses are in Java, and it is unrealistic to expect a teacher to ask their students to use multiple programming languages because the focus is on learning Java well enough to pass the AP exam, not to learn to program generally.

Does something which will compile Java code to an arduino hex file exist? It seems like a long shot, but it would be amazing if this existed. If not, is there a Java VM that can be run on an arduino? That seems similarly like a long shot given the limitations of the microprocessor, but might be good enough given that my arduino is running almost no other code (I put most of the auxiliary control hardware on other chips to leave more cycles free on the arduino to work with).


Does something which will compile Java code to an arduino hex file exist?

Not that I know of.
However, most of Java that does stuff, is actually in C so there is not a lot of difference.


Just lean Java at collage, and learn c++ (arduino) your self. They are similar enough for the beginner. With a beginners guide to ansi c++ and some classes in Java you will be fine as far as learning arduino go. Obviously a lot of what you will learn in Java will not be relevant to arduino. It's the program structure your interested in. There is some difference. Java has no functions just class's. You will uses a lot of functions working with the arduino. Variables are different in c++ (arduino) you have to define the type (int,float,char..) in Java you dont.
Other than that they are very similar to the beginner.  


You may be in luck.  There is a Java Virtual Machine for the AVR family of processors of which the ATmega328p is a member:


Looks like your Java byte code goes into EEPROM.

The source code can be downloaded from http://sourceforge.net/projects/nanovm/
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Brian Neltner

I agree 100% that writing code in C or C++ or processing or whatever is minimally different than Java, but for what I'm making to be usable by a high school teacher it has to fit a need in the curriculum (which is Java).

Personally, I don't even know Java, I use C and python almost exclusively because I am always doing either embedded work or writing trivial computer software for numerical analysis (where the time it takes is not very important). I only even use C++ when someone else wrote it and I need to adapt or fix it.

But if the schools say their kids need to learn Java, I don't really have a great deal of flexibility to say that they should learn something else. I could say "use this for after school projects", but kids are so busy it seems unreasonable to expect them to do that if it is at all possible to use what they will already be familiar with.

I am excited about the java VM that uploads the bytecode. I wonder if that can be incorporated into the bootloader (or if that's even necessary). I will definitely look more into that, thanks very much for the reference.

Go Up