Anyhow. Space is at a premium on the Pi, so I thought I'd try installing a JVM/JDK on my CIFS mounted file-system that actually lives on my desktop PC. Unfortunately, that filesystem is NTFS (underneath the hood), and that means it doesn't support Unix-style soft links... and the JDK that is available for the Pi (OpenJDK) is full of them, even once you get through the layers of soft links around the file system that lead to /usr/lib/jvm/java-6-openjdk. So, the network mount was out of the question. (Maybe someone, somewhere, has instructions for creating a virtual file system in a file on a network share, where the filesystem inside is something more native to Debian Squeeze Linux).
The not so bad news is that OpenJDK 6 is actually only (only?) 108Mbytes, which I can afford as long as I keep my project code on my projects drive. So, assuming your system is setup as I've described in previous posts:
- SSH/VNC to the Pi, logging in as 'pi'
- Run "ln -s /mnt/projects" to create a projects folder in my home directory that's actually safely squirrelled away on my PC. (auto-magically double backed-up every night via SyncToy and DropBox, by the way)
- Now install the OpenJDK version 6 (I'll save JDK 7 for another time as that's a whole different kettle of rather narsty fish!): run "sudo apt-get install openjdk-6-jdk"
- It takes a while, but when it's done, "which java" should give you:
pi@raspberrypi:/$ which java /usr/bin/java
- and "java -version" should give:
pi@raspberrypi:/$ java -version java version "1.6.0_18" OpenJDK Runtime Environment (IcedTea6 1.8.13) (6b18-1.8.13-0+squeeze1) OpenJDK Zero VM (build 14.0-b16, mixed mode)
- Now run "sudo apt-get clean", to remove the cached installation files from the various tools you've installed - I found this saved about 50Mbytes of space, so a not inconsiderable saving on such a small file system.
- Now to write some Java code.
That is exactly my plan for my raspberry pi too!, how did that go? Were you able to run standalone java apps? what about a tomcat instance!?.
ReplyDeleteBest regards.
Yes it did work - including writing a small web server of my own.
DeleteTomcat might work, but I've not tried it.
Jetty would also be worth a try if your looking at small web servers.
Hi!
ReplyDeleteI received today my raspi and I just downloaded and installed the openjdk from the repositories. I searched about installing Java on the raspi and I found this: http://www.oracle.com/technetwork/articles/java/raspberrypi-1704896.html
java SE for Embedded. I'm wondering: why using this instead of using directly the openJDK for debian? Because for me works perfectly (it's true that the compilation takes a bit). It's about performance? The openJDK performance in the raspi is worst than the Embedded version?
Do you know why?
Thanks.
Best Regards
Hi Shuco,
Deletelooks like that article was published in August, some time after I posted mine in July, so I don't know if there are any performance reasons for their choice of the Oracle jdk. However, as it's an article on the Oracle site, I suspect that's their reason for using it. :)
I've just reformatted my Pi as an XBMC machine, so I'm not in a position to compare them. But, if you do any comparative tests yourself, I'd be interested in the results.
Thanks you, I installed Java, below is output
ReplyDeletepi@webserver ~ $sudo apt-get update
pi@webserver ~ $sudo apt-get install openjdk-6-jdk
pi@webserver ~ $ which java
/usr/bin/java
pi@webserver /usr/local $ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-1+rpi1)
OpenJDK Zero VM (build 20.0-b12, mixed mode)
Regards
Ranganath
I believe Openjdk does not have jit compiler so is slower. Tomcat7 runs but I find jsp files take about 10-15 seconds to open.
ReplyDelete