Author Topic: Question about java  (Read 2874 times)

0 Members and 1 Guest are viewing this topic.

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Question about java
« on: January 21, 2012, 10:32:32 pm »
So I hear that Java is very technological-device-wise. Meaning that the main purpose of Java is to be able to run on any electronic device.
I did some research about that fact and I didn't find much, but some guy mentioned that he saw electronic devices such as a Microwave programmed in Java. I did little searching on that microwave java thing and all I was able to find was some exercise to calculate food cooking time or some shit...

Seeing that Java was used for mobile phones since polyphonic melodies appeared - it's then when phones started to get smarter, with color screens and stuff.

Anyway, Java was on phones for ages and even android apps have to be made in Java (not anymore but at first...).

As they are teaching us at school, Java is also used by corporations as THE language, teachers told us that banking operations are spinning on Java code.
Now with each day I am starting to understand the purpose of Java... and all those java rap videos...

I drifted away a little from my main question - where can Java be used somewhere else, apart from being a desktop/mobile app platform. Can it really be used to program such things like Microwaves?

Offline ca0s

  • VIP
  • Sir
  • *
  • Posts: 432
  • Cookies: 53
    • View Profile
    • ka0labs #
Re: Question about java
« Reply #1 on: January 21, 2012, 10:53:35 pm »
For what I know, Java is usable almost in every system where the Java Virtual Machine can be installed, and when system resources or speed are not important at all.

Offline darkwolfzero

  • NULL
  • Posts: 3
  • Cookies: 0
    • View Profile
Re: Question about java
« Reply #2 on: January 24, 2012, 04:39:59 am »
I'm curious about this as well.  I'm currently trying to get something working with a mechanical engineer friend of mine, and I have no idea where to start.  I can program java quite well, but I have only deployed programs on computers and android.  We are looking to create a device that is controlled via bluetooth from android and to retrieve some data.  I'm just curious about what equipment we will need for the device itself and how to get the java application installed on it and how to program the device to do the actions we what it to do.  Sorry, I can't be of much help on the microwave question, but I am there with you on the curiosity level. 

Offline _moon

  • /dev/null
  • *
  • Posts: 10
  • Cookies: 1
    • View Profile
Re: Question about java
« Reply #3 on: January 24, 2012, 10:50:46 pm »
Technically yes. Java can be used to program anything, as long as you have the resources to run the jvm, as ca0s said.


However, to use Java to program something like a microwave, you need a jvm that knows how to translate the java bytecode (compiled java classes) to the underlying hardware components.


There are many existing jvms, which goals vary from increased performance on specific processor architectures to reduced footprint. You can try to take a look at this page :
Code: [Select]
http://en.wikipedia.org/wiki/List_of_Java_virtual_machines


All those moments will lost in time, like tears in rain.

Offline _moon

  • /dev/null
  • *
  • Posts: 10
  • Cookies: 1
    • View Profile
Re: Question about java
« Reply #4 on: January 25, 2012, 12:44:43 am »
 @darkwolfzero :


I believe I have an example that may help you get started.


A few years ago, I had to code an implementation of an ad-hoc routing protocol (AODV) for a set of wireless sensors. These sensors were running TinyOS, an open source operating system written in a C variant called nesC (network embedded systems C). They were able to measure light, temperature and sound from external sensors, and used a tiny wifi antenna to transmit data packets.
Code: [Select]
http://www.cmt-gmbh.de/Produkte/WirelessSensorNetworks/MICAz_2.4_GHz.html

The actual challenge was the routing protocol, probably not very interesting to you. Nonetheless, to measure the effectiveness of the protocol, I had to be able to receive and display all the data sent by the sensors on a computer.


So, how would you do that ?


The first step was to code the sensor application using the proprietary language nesC. In my case, each node had to regularly retrieve external temperature, pressure, and luminosity from the sensor, and then send the information to the base station using the wifi antenna. They also served as relays for other nodes.


The sensors were programmed using an ethernet board like this one :
Code: [Select]
http://www.cmt-gmbh.de/Produkte/WirelessSensorNetworks/MIB600_Ethernet_Gateway.html

Finally, the data packet sent by the sensor looked like something like that :
Code: [Select]
typedef nx_struct Msg {
  nx_uint8_t id;     // emitting node id
  nx_uint8_t src;    // source node id
  nx_uint8_t dest;   // destination node id
  nx_uint8_t ttl;    // Time To Live
  [...]
  nx_uint16_t valL;  // luminosity sensor value
  nx_uint16_t valS;  //  sound sensor value
  nx_uint16_t valT;  //  temperature sensor value
} Msg;


Then, all I had to do was to write a Java application that could read such messages when listening to a specific port.
Code: [Select]
public Msg(byte[] data) {
  ...
}
...
public int getId() {
  return (int) funtionToGetContentFromByteArray(0, 8);
}


 I could then draw a map of sensors, display the local temperatures etc to my liking, and most importantly see how effective my protocol was just by looking at the packets.
 


This is a very simple example, but you can adapt to your use case. You'll probably have to write a Java class for sending/receiving packets with Bluetooth. You'll have to code different types of control messages, and since Bluetooth isn't restricted to your own device, you'll need a reliable way to check what you receive.


As for the device, well everything depends on what it is ! ;)
« Last Edit: January 25, 2012, 12:47:06 am by _moon »
All those moments will lost in time, like tears in rain.

xor

  • Guest
Re: Question about java
« Reply #5 on: January 25, 2012, 01:09:18 am »
As it has already been stated on this thread many times (I'm only answering because Kulverstukas asked me to), but while touted as `Platform Independant`, Java can't run on anything but the Java Virtual Machine, this actually making it very platform dependant.

The reason why Java can be run on so many things, including your microwave, is because the JVM is often adapted to the environment it will be running in. Sun no doubt have made all of the base JVM's for Windows and Linux, but the JVM is also open source, meaning that any developer wishing to implement it on their own device can compile a version suitable to the hardware platform, allowing them to write code for it.

This is exactly what happened with android, the base system is Java sure, but they had to add in a lot of additional functionality in an API to allow people to do what they do with the development kit.

Offline Python

  • /dev/null
  • *
  • Posts: 6
  • Cookies: 0
    • View Profile
Re: Question about java
« Reply #6 on: February 08, 2012, 10:47:43 pm »
It was originally developed to be used in household appliances, for example, as you mentioned microwaves, even things like toasters. It can be used on tons of different hardware variants, just as long as the java virtual machine can be installed.