OEM Newbi: How do I put a small Java application on a custom hardware platform?
I'm still learning Java, but would like to embed a small Java program on a custom hardware device. I do however seem to be missing a degree in engineering... but perhaps someone here can point me in the right direction?
I would like to do something very very small and simple. My idea is to write a small Java application that controls 10-20 LED lights and make them flash in different patterns.
I would like to build (or purchase) a small custom 开发者_如何转开发device and place my Java application on it, thus having a small custom box with an "on" and "off" switch that would run my Java code, which would then be controlling the LEDS. When I flip the switch my code runs!
Are there starter kits or tutorials for this sort of thing? Would I need to buy a soldering ironiron...? I have tried google, but I am not sure what to actually google... Any guidance would be appreciated.
You would have to compile the a JRE, most likely some version of J2ME for your selected hardware, a better choice is Arduino, and just bite the bullet and learn enough the Arduino langauge based on C/C++ Syntax to get by. There are lots of resources on the web for this board.
The problem with Java is that, while the class files are often tiny, there's a honking big runtime required to run them. Java SE is several megabytes. Java ME is made for embedded devices (think phones) and is smaller but not by much.
To get Java running on a piece of hardware, someone must port the Java runtime to run there. This really is a job for a systems engineer, as I think there's some low-level hacking involved. Certainly parts of the system will need to be re- and custom compiled.
As a rule of thumb: If whoever provides your hardware provides a Java runtime or mentions that one is available, all is well. If not, you need to go looking for a different solution.
At one point about 10 years ago, Sun was actually planning to create "Java chips," custom CPUs for running Java bytecode, and these would have been great for embedding Java in your toaster. However, they apparently did the numbers and concluded that it wasn't a viable business proposition. So Java today still does not run everywhere.
Regarding the part of your question looking for general guidance, look at this fine web site using the embedded tag.
For something to become very small and very simple you need to end up with native machine code.
Anything Java basically means you need to bring in a Java interpreter with Java libraries etc. etc. which automatically means that "very small" cannot be achieved. A few hardware platforms can help interpreting Java, but you still need the supporting runtime libraries.
For "very small" you still need to use C (or perhaps C++) and cross compile to the target platform.
Please learn C. This language is (next to assembly) the closest to the embedded machine you will be trying to program. C is not hard and the language manual is about 130 pages, not 600+ pages as with java. And you don't have to learn the whole language.
Arduino is a great platform to start with, but you will need to learn C for that.
精彩评论