1 (edited by stonechild 2011-01-20 17:28:44)

Topic: Oracle's Embedded Java

I'm trying to get Embedded Java running on an Insignia Forecast 8" and don't understand how to set up the Flash Drive.  On the drive I have the Java folders bin, lib,and css, and legal. bin contains java. I added /mnt/usb/bin to the PATH in .profile, but java is not found.

I admittedly have no experience in using a USB Flash drive to do what I would like to do. Any help would be much appreciated.

Embedded Java and some info on system requirements is at:

http://www.oracle.com/technetwork/java/ … 59989.html

Dennis

2 (edited by clay_shooter 2011-01-16 17:49:12)

Re: Oracle's Embedded Java

So the Oracle download looks like just the java embedded runtime.

Here's what I did to verify it "works" on the Infocast/chumby

Download the ARM v5 version to the flash drive. It is a "headless" java for the Chumby CPU.
Inserted the flash drive into the Infocast.
ssh into the Infocast
unzip and untar so that you get a directory called ejre1.6.0_21. 
I generally work in /mnt/storage so I moved  ejre1.6.0_21 to /mnt/storage
    mv /mnt/usb/ejre1.6.0_21 /mnt/storage
Then in my shell prompt I typed the following two lines.  You could put them in your .profile
    export JAVA_HOME=/mnt/storage/ejre1.6.0_21
    export PATH=$JAVA_HOME/bin:$PATH
Then I could verified with
    java -version
which returned
    java version "1.6.0_21"
    Java(TM) 2 Runtime Environment, Standard Edition for Embedded (build 1.6.0_21-b09, headless)
    Java HotSpot(TM) Client VM (build 19.0-b02, mixed mode)

It's the standard Java SE and not the "different" Java ME.  It is binary compatible with code compiled on your desktop because it uses Java Bytecode.  I copied a simple HelloWorld.class file to my chumby and in a shell window, that had the environment variables from above, typed
    java HelloWorld
and it ran printing out Hello World!

Re: Oracle's Embedded Java

clay,

Thanks very much for showing me how to do this.  It's pretty much the same as on other linuxes.

My problem seems to be going back and forth between Windows and Linux.

Re: Oracle's Embedded Java

This got me curious what else you could do with Java on one of these.  I was able to run one of the Phidget java example programs for my InterfaceKit 0/16/16 board.  The Phidget java example uses the phidget.jar which then uses the libphdiget21 library using JNI. 

Mumble mumble, techobable.  The net is that a java program on the chumby used a JNI library that then talked to libhid that then talked to a USB interface board.  (Hmm that still kind of sounds like technobabble)

Re: Oracle's Embedded Java

As far as I can tell, I followed the procedure you describe. Unfortunately for me. when I type "java -version", I get "Illegal Instruction".  I'm downloading embedded headless Java for ARM v6/v7 under Ubuntu running in VirtualBox hosted by Win 7 to a USB drive which I then plug into the Forecast 8" .

Any suggestions. I've done the download several times. It's  probably some simple thing that I've overlooked.

I've been thinking about buying the Phidget 8/8/8 as part of a way to get Java running on some kind of embedded device with USB. Now if I get Java running on the Forecast, I will probably buy the Phidget 8/8/8 since it seems it would  make connecting to sensors easier.

Re: Oracle's Embedded Java

Did you set your JAVA_HOME and PATH variable in your shell before typing java-version?

I only tested the output side of my interface card.  I haven't had a chance to play with the input side.

Re: Oracle's Embedded Java

clay_shooter wrote:

Download the ARM v5 version to the flash drive. It is a "headless" java for the Chumby CPU.

stonechild wrote:

As far as I can tell, I followed the procedure you describe. Unfortunately for me. when I type "java -version", I get "Illegal Instruction".  I'm downloading embedded headless Java for ARM v6/v7 under Ubuntu running in VirtualBox hosted by Win 7 to a USB drive which I then plug into the Forecast 8" .

Sorry, observer couldn't resist pointing this out.

Re: Oracle's Embedded Java

Madox is correct - the processors in these devices (except for the Sony dash) use the ARMv5 instruction set.

Re: Oracle's Embedded Java

Good catch. I missed the processor comment. 

For others... You don't need a desktop linux for any of this.  I compiled my java programs under windows and put the .class files and the java package on the thumb drives.  Then I stuck the thumb drive in, SSH'd into my Infocast and uncompressed and untar'd java directly on the box from my SSH window.

Re: Oracle's Embedded Java

Hey, by the way, the Java dongle I made a while back (linked on the wiki) includes Jikes, so it's possible to compile Java on the device, too.

Re: Oracle's Embedded Java

Finally, thanks to clay_shooter and Madox for their suggestions.  At first, I  tried using Embedded Java Arm v6/v7 Headless since the Infocast 8" uses an ARM9. Switched  to  Embedded Java Arm v5 Headless. Still didn't work!

It turned out that I was uncompressing the file with the wrong set of commands

Now I get the Java version and the "Hello, World" program works..

The only reason I used Linux was because I didn't know what the problem was and was floundering around as you may have guessed.

The Hello, World was compiled using Eclipse on Windows 7

12 (edited by RichR 2011-03-12 14:04:35)

Re: Oracle's Embedded Java

The Oracle Java SE will run a nifty code example illustrating  UDP Client / UDP Server communication, the source is found at:
http://sysbash.com/3j

...I copied the above source into two files, UDPClient.java and UDPServer.java, editing the UDPClient.java to use the IP address of my Infocast.
The client and server code was compiled on my WinXP machine using the following .cmd script (or just type it in by hand):

:: myUDPProject.cmd
:: PURPOSE
:: Simple batch file to Compile and build the UDPClient.java and the UDPServer.java application.
:: ===============================================================

:: set the locations CHANGE THESE PATHS TO POINT TO YOUR JAVA JDK
set JAVACPATH="E:\Program Files\Java\jdk1.6.0_24\bin"
set JARPATH="E:\Program Files\Java\jdk1.6.0_24\bin"

:: Compile the client
%JAVACPATH%\javac.exe UDPClient.java
pause
%JARPATH%\jar cvfm UDPClient.jar Manifest.txt *.class
pause

:: Compile the Server
%JAVACPATH%\javac.exe UDPServer.java
pause
%JARPATH%\jar cvfm UDPServer.jar Manifest.txt *.class
pause
:: End of myUDPProject.cmd

Then I copied the UDPServer.jar to  /mnt/usb/
and ran it using the following (while connected using an SSH session):
     cd /mnt/usb
     java -jar ./UDPServer.jar

...On the WinXP computer I started the UDPClient.jar from the command line using   java -jar ./UDPClient.jar
Typing text on the WinXP machine then pressing <Enter> sends that text to the Infocast, which converts the text to upper case and sends it back to the client. The client exits, but the server keeps running until you press <CTRL-C>.
Only one server instance is allowed on a port at a time; starting a second server instance on the same port will display "Address already in use" error.

13 (edited by stonechild 2011-03-26 12:03:57)

Re: Oracle's Embedded Java

This Internet example is really neat.  It will, no doubt, be the base for other code..

Thanks Rich