This discussion is archived
3 Replies Latest reply: Feb 12, 2008 4:04 AM by 843851 RSS

How do i connect my hardware to java program ?

843851 Newbie
Currently Being Moderated
Hello Gems,
How do i connect my java application to outside world? It will come under embeede systems know. I want to get explore to embeede systems. please help. If any new special hardware require to my system to act as interface?

Help me....!
  • 1. Re: How do i connect my hardware to java program ?
    843851 Newbie
    Currently Being Moderated
    I think you are asking "how does the JVM (and my java program) know how to communicate with specialized hardware that is connected to external devices (the outside world)?" Is that a fair restatement?

    Embedded Java Systems work essentially the same way as your desktop/laptop computer. In order for Java to know how to communicate with hardware you will need to add an API (and that will probably have some native methods). Take a simple example, a GPS unit with a serial interface (RS-232). Java does not know how to talk to a serial device, so you need to teach it by adding the javax.comm API or the rxtx gnu.io API. Once you have properly added that to the Java runtime and classpath then you can write java programs that can find serial ports, open them, and send data back and forth between your Java program and the serial device. You will also need to know the specifics on the data that the GPS device sends and receives through its serial interface.

    This is the essence of ALL java-hardware interfaces, embedded systems or not: you need an API and native methods. If you look hard enough you can find an API for most desktop/laptop interfaces (serial, USB, Bluetooth, Firewire). In some cases you will need to write your own native interface and java wrappers. For example if you wanted to write a java application that will get the temperature and fan speed from the senors internal to your computer. You could use the lmsensors project and write a simple native interface to bridge between java and the lmsensors code.

    When working on a embedded system, you will have a much wider choice of interfaces to deal with (I2C, SPI, GPIO, Serial, CAN, bluetooth, USB, 1-wire, etc, etc, etc). In each of these cases you will need to find, write or purchase an API that enables Java to communicate with devices connected to these interfaces. This is one of the benefits of using a Java Embedded Systems: they usually have all of the necessary APIs included as part of the JVM or the build environment.

    Take a Java capable cell phone as another example. If the cell phone vendor has implemented the Connector class for the serial port (its optional) then you can open a Connection to devices connected to your phone's serial port. If the phone supports Bluetooth AND if the vendor has implemented JSR-82 (the bluetooth API) then you can open connections with nearby Bluetooth devices.


    Dan
  • 2. Re: How do i connect my hardware to java program ?
    843851 Newbie
    Currently Being Moderated
    hi

    i want to write a bluetooth application where my cell phone becomes a remote for my pc such that i could shut down my pc and do such related hardware stuff from my cell.I am using JSR82 and J2ME how can i do this.
    Plz help me out???
  • 3. Re: How do i connect my hardware to java program ?
    843851 Newbie
    Currently Being Moderated
    Hi, I have been google'ing for a while now and cant really find what I want. I can program in Java and is now wanting to learn how to program electronics like for example switch my room's lights on and off etc... Can someone please help me or at least tell me where to start (e.g. a tutorial's link)

    Thanks for in advance