19

I have been looking into micro-controllers and was wondering if the majority of them are C/C++ based? I am quite proficient in java and want to ask you guys if anyone knows of a good cost efficient, java-based micro-controller I could look into.

All answers are appreciated!

MWiesner
  • 8,868
  • 11
  • 36
  • 70
user2855405
  • 495
  • 2
  • 7
  • 20
  • 1
    The languages are so similar that you should just switch to a good micro-controller with a good community and learn. For instance Arduino is a subset of C#, but it is not that crazy to learn coming from Java... – DrCord Nov 20 '13 at 17:56
  • 2
    @DrCord ??? Arduino is programmed in C or C++. There's no C# or subsetting involved whatsoever. –  Nov 20 '13 at 18:02
  • @H2CO3 I didn't believe it either, but [here](http://playground.arduino.cc/Interfacing/Csharp) it is. Of course, other than for a hobby I don't know why you would program an embedded system using C# or Java. – jmstoker Nov 20 '13 at 18:04
  • @jmstoker "it **can** be programmed in C#" does not mean that C# is the default/official/most used language. (Which it isn't, because those are C and C++. Of course, I have as well tried to compile my own [scripting engine](http://github.com/H2CO3/Sparkling) and run a program on an 8-bit AVR, but that's C too, so...) –  Nov 20 '13 at 18:06
  • Yeah, sry I was wrong I guess, I had read and been told it was a subset of C#. – DrCord Nov 20 '13 at 18:10
  • @user2855405 What is your motivation for programming on a microcontroller? For fun or do you want to enter the field of embedded development? – jmstoker Nov 20 '13 at 18:12
  • @user2855405: jmstoker has a good point, if you want to enter the field of embedded development it is a must til learn C. One really can not do embedded without it as a professional. – uniquenamehere Nov 21 '13 at 01:05
  • 1
    IM not so HO, you should not be even *considering* programming anything other than a high end embedded processor using Java. It's too slow and far too much of an overhead using Java for processors that can't run something like Linux. AVRs, Cortex M3/M4s and similar are simply not suitable for using Java. Also, the idea that a processor is C/C++ based is a bit of an odd expression. No processor is based on any language other than, you could argue, its native assembly language. – DiBosco Nov 21 '13 at 09:48
  • In the early days of java and folks were talking about embedding java, the Dallas Semiconductor TINI boards came out. Dallas is now Maxim. Basically an 8051 with a ton of ram relative to what a microcontroller would normally need. itai basically answered the question, you either need hardware or software virtual machine support and you have to somehow deal with the lack of an operating system for those calls. Possible but not practical until you get on the higher end of microcontrollers. – old_timer Nov 21 '13 at 14:50
  • The difference between microprocessor and microcontrollers is getting fuzzy, and both of them today have the power of a small datacenter in old days. You could just use a Raspberry PI and have it run Java code. As always in embedded systems, watch the resources and decide where to spend them. – Queeg Jan 12 '23 at 22:16

5 Answers5

16

The difference between a language like java (or c#) and a lower level language like c or c++ is the fact that they have a virtual machine. This has many advantages, like making the application platform-independent. But it also means that each platform has to have the vm for it.

Now, microcontrollers are not uniform and vary in power, memory, and many other features. So adopting the JVM (java's virtual machine) for them is not easy even when possible. Most of the time its just impossible - most of the uc have very low memory capacity (part of what makes them cheap) - this would make fitting any general-purpose JVM there impossible, not to mention also with the application code.

I am aware of some partial-implementations of java for microcontrollers. For example "java-based" sim cards (which have a very small controller inside) are there, but they have a very limited version of java.

So basically I think your best bet to write "embedded java" (especially if you're a novice) is to work on top of microcontrolers that are basically a small fully functioning computer, that runs a proper OS that already has a JVM. Just look into one of the new "micro computer" open source projects like raspberry pi or beaglebone. Both cost around 2x of an arduino and are much more powerful.

Hope I helped.

itai
  • 1,566
  • 1
  • 12
  • 25
  • "Now, microcontrollers are not uniform and vary in power, memory, and many other features. So adopting the JVM (java's virtual machine) for them is not easy..." - yes it is, actually. That was the entire point of the JVM. It was literally targeted for heterogeneous embedded systems. The RAM concerns still stand though. – user515655 May 19 '23 at 02:08
11

Have a look at the Java-ready STM32 microcontrollers or Renesas RX.

As an alternative, you can run a stripped-down JVM on AVR/Arduino using Haiku-VM, NanoVM or uJ.

You can also write Arduino sketches in Java and cross-compile them to C using VBB.

niutech
  • 28,923
  • 15
  • 96
  • 106
5

JArduino might be a good starting point for you, as it would allow you to write Java programs that interact with an Arduino board. The Java API provided by JArduino is fully aligned with the Arduino API. Then, once you get used to the Java API, it should be easy to switch to plain Arduino programming (as pointed out, the C/C++ -based Arduino is not that far from Java, anyway). Be aware that with JArduino you do not really program the micro-controller itself (your main logic would run on your PC and the Arduino would simply be "controlled" without any advanced logic running on the board).

bmorin
  • 645
  • 5
  • 12
3

There are Java alternatives, but I think they are costly. For example ST Microelectronics has this java IDE based on eclipse:

Java SDK

I have no experience with java on microcontrollers, but Java have many similarities (C based language) to C++ (which is more supported with microcontrollers), but it is still C that is dominating. It should be possible to learn this quite fast if you already know Java.

Arduino uses C++ and are easy to use for people inexperience with C/C++.

I suggest you also try the STM32 Java forum to see if there are users already sharing their experiences:

STM32 Java forum

uniquenamehere
  • 1,869
  • 3
  • 31
  • 60
  • So the first link you gave me, what is the purpose to that software? Does it link to a micro-controller? – user2855405 Nov 20 '13 at 18:08
  • 1
    @user2855405: As far as I understand you can flash the microcontroller from the IDE. On the bottom of that page you can find a lot of PDF documents that will explain what the software can and can not do, but here is quote from one of the documents: _"STM32Java is a complete solution to develop and deploy applications on STM32 microcontrollers using Java technologies"_. – uniquenamehere Nov 20 '13 at 18:12
1

You can look at Java on a Chip (JoC Module) is the java programmable controller-module

JoC have a reference Board Javaino for easy development

Also Demmel iLCD product have the Java VM on board, it's a smart display with JVM

452
  • 396
  • 4
  • 9
  • 24