view · edit · print · history

Java on DS101g+

It is perfectly possible to install and run a Java based servlet and JSP environment on the 64 MB PowerPC based DS101g+. In the following this is achieved by manually installing IBM's PowerPC based Java SDK and the popular Jetty servlet and JSP engine.

It will probably also work on DS106 and other Synologys based on PowerPC and with at least 64MB RAM.

Note that it is not necessary til install the Optware-hack in order for this to work, but you have to be able to telnet into the device.

Please note that I take no responsibilities whatsoever for this description.


In order to be able to telnet to the DS101g+ you must update it with flipflip's telnet enabler. Find it at http://oinkzwurgl.org/diskstation it is named syno-telnet-r4.zip. Follow the instructions for installation. Afterwards you should be able to get a telnet command prompt on the DS101g+. Recent firmware on some Synologys (not the DS101g+) includes built-in support for telnet.

If you are on a Windows box, select Start-->Run and enter cmd.exe. You get a command window, and here you enter telnet <ip>, where <ip> is substituted with the ip-number of your DS101g+. Log into user root with your administration password.

If the directories /opt/local does not exist, create them:

cd /
mkdir opt
cd /opt
mkdir local

Obtaining a Java SDK

IBM offers a free Java 5 SDK for PowerPC, which works flawless on the DS101g+. Preliminary testing of IBM Java 6 indicates slower perfomance on the Synology than Java 5. The URL are http://www.ibm.com/developerworks/java/jdk/linux/ select the download link and download the tgz SDK marked 32-bit iSeries/pSeries. Currently this is in Service Release 6 and the file name is ibm-java2-sdk-50-linux-ppc.tgz. You are required to register (free) with IBM in order to make this download. Place the downloaded file on /volume1/public on your DS101g+.

Installing the Java SDK

Telnet into the DS101g+ and untar the tgz file:

cd /opt/local
tar -zxvf /volume1/public/ibm-java2-sdk-50-linux-ppc.tgz

Make a symbolic link to the Java directory:

ln -s ibm-java2-ppc-50 java

Now you should be able to verify that Java is installed and functioning with the following command

/opt/local/java/bin/java -version

The result should be similar to this:

java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pxp32dev-20061002a (SR3) )
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Linux ppc-32 j9vmxp3223-20061001 (JIT enabled)
J9VM - 20060915_08260_bHdSMR
JIT  - 20060908_1811_r8
GC   - 20060906_AA)
JCL  - 20061002

A Servlet engine

To actually use Java, you need at least a servlet- and JSP-engine. Many exists, but here we use the popular and efficient Jetty server. The latest version as of writing is version 6 and it is capable of servicing many simultanous connections with only a small resource consumption.

Obtaining Jetty

Jetty can be found on http://dist.codehaus.org/jetty/. Currently it is only available as a zip-file named jetty-6.1.7.zip.

Unzip the file and place the top directory on the public share on the DS101g+.

Locate the file jetty.sh in the bin directory of the Jetty distribution and start editing the file. Remove the two lines containing the word 'disown' towards the end of the file. You can do this in the telnet session with the builtin vi editor, but it is quite difficult to use. Instead you can use the Windows Notepad editor, but the script looks garbled due to different line termination characters in Windows and Linux. With Notepad, search for 'disown \$PID' (without quotes) and delete it. Save the file afterwards.

Now move the Jetty directory to /opt/local in your telnet session:

cd /opt/local
mv /volume1/public/jetty-6.1.7 .

Establish a symbolic link to the server:

ln -s jetty-6.1.7 jetty

In order to easily start and stop the Jetty server make a command script with the following contents:

#echo $1
export JAVA_HOME=/opt/local/java #
export JETTY_HOME=/opt/local/jetty #
export JETTY_PORT=8080 #
if [ "$1" = "check" ]; #
then sh /opt/local/jetty/bin/jetty.sh check #
else if [ "$1" = "stop" ]; #
then sh /opt/local/jetty/bin/jetty.sh stop #
else sh /opt/local/jetty/bin/jetty.sh start #
fi #
fi #

This script can be built on Windows and copied to your public drive on the DS101g+. The # at the end of each line shields against line-ending problems. Name it S85jettyd.sh and in your telnet session copy it to the right place:

cp /volume1/public/S85jettyd.sh /opt/local/jetty/bin

Start it like this:

sh /opt/local/jetty/bin/S85jettyd.sh start

Try URL http://<ip>:8080/test/ from your favourite browser (allow some time for jetty to start). Stop jetty by invoking the command script with the stop option:

sh /opt/local/jetty/bin/S85jettyd.sh stop

If you want to check parameters, use the check option:

sh /opt/local/jetty/bin/S85jettyd.sh check

If you have installed Optware you can copy the script to /opt/etc/init.d directory. It will then autostart on boot.

cp /opt/local/jetty/bin/S85jettyd.sh /opt/etc/init.d

The log file is located in the /opt/local/jetty/logs directory.

Note that the first time servlets and JSP's are executed they are compiled, which can take a significantly amount of time. Next time the same servlet is executed, the compiled version is used, yielding much better performance.

view · edit · print · history · Last edited by ByronT.
Based on work by Peder Madsen and fcarolo.
Originally by Peder Madsen.
Page last modified on January 04, 2008, at 11:52 AM