Java SE Embedded package for Synology NAS

UPDATE 4 – Now supports DS414j!
UPDATE 3 – Now with Java 8, and full support for all versions on Intel CPUs running DSM 5.0!
UPDATE 2 – Now running on PowerPC 2010 Synology models running DSM 5.0 beta!
UPDATE – Now running on Armada 370/XP (ARMv7) and Intel Atom Evansport CPUs, as used in some x14 series Synology models!

There is a lot of good Java software, but it’s difficult to get Java running on a NAS. I decided to do something about that, mainly to pave the way for a Serviio package that didn’t require a huge guide to install. To stay legal, I followed how QNAP packaged Java for their NAS products. The Java binaries cannot be redistributed so this package looks for the downloaded .tar.gz archive in the public shared folder on the NAS. The end user is required to register with Oracle to get the file, as you can see from the description below. I also added locale support to the underlying Linux since Java requires this for UTF-8 support when reading from the filesystem.

Only Marvell Kirkwood, Marvell Armada 370/XP, Intel, and Freescale QorIQ/PowerQUICC PowerPC CPUs are supported, so please check which CPU your NAS has. Java 7 for Intel Atom CPU does not currently work on Synology systems running DSM versions older than 5.0, so those users are limited to Java 6. Though Oracle have published a JRE for PowerPC, it also requires DSM 5.0. PowerQUICC PowerPC synos running older DSM versions do not have a recent enough glibc version (2.3.4, but Oracle’s Java needs 2.4). It is technically possible to run Java on those units, but it requires chroot-ing to a Debian install which can get complicated. Christophe from chreggy.fr has recently released packages to automate this.

Java package for Synology

 

Instructions

  • If you have a multi-bay NAS, use the Shared Folder control panel to create a shared folder called public (it must be all lower case). On single bay models this is created by default. Assign it with Read/Write privileges for everyone.
  • Register with Oracle and download Java SE for Embedded 7 for either ARMv5, ARMv7 Headless Server, or PowerPC e500v2 as appropriate (Intel NAS users will need the end-of-life Java SE for Embedded 6), and save in the public shared folder. If the file isn’t found an error message will display the full expected filename. You cannot use a different version by renaming it, since the folder structure inside the archive will be different.
  • Install the Java package from the DSM Package Center. In Settings -> Package Sources add my package repository URL which is http://packages.pcloadletter.co.uk. My packages will appear in the Community section once the repo URL is added.
  • If you have trouble getting the Java archive recognised, try downloading it with a different web browser. Some browsers try to help by uncompressing the file, or renaming it without warning. I have tried to code around most of these behaviours.
  • The package does not need to start, just installing it is sufficient.
  • If you update DSM later, you will need to re-install this package or else UTF-8 and locale support will be broken by the update.
 

Package scripts

For information, here are the package scripts so you can see what it’s going to do. You can learn more about how Synology packages work by reading the Synology Package wiki.

installer.sh

#!/bin/sh

#--------JAVA installer script
#--------package maintained at pcloadletter.co.uk

COMMENT="# Synology Java Package"
SYNO_CPU_ARCH="`uname -m`"
[ "`echo ${SYNO_CPU_ARCH} | cut -c1-7`" == "armv5te" ] && SYNO_CPU_ARCH="armv5tel"
cat /proc/cpuinfo | grep "Comcerto 2000" > /dev/null && SYNO_CPU_ARCH="armv7l-neon"
[ "${SYNO_CPU_ARCH}" == "x86_64" ] && SYNO_CPU_ARCH="i686"

if [ "${SYNOPKG_PKGNAME}" == "java6" ]; then
  DOWNLOAD_URL="http://tinyurl.com/javaembedarchive"
  EXTRACTED_FOLDER="ejre1.6.0_38"
  if [ "`echo ${SYNO_CPU_ARCH} | cut -c1-7`" == "armv5te" ]; then
    JAVA_BINARY="ejre-1_6_0_38-fcs-b05-linux-arm-sflt-eabi-headless-13_nov_2012.tar.gz"
    JAVA_BUILD="ARMv5 Linux - Headless EABI"
  elif [ "${SYNO_CPU_ARCH}" == "armv7l" ]; then
    JAVA_BINARY="ejre-1_6_0_38-fcs-b05-linux-arm-vfp-eabi-headless-13_nov_2012.tar.gz"
    JAVA_BUILD="ARMv6/7 Linux - Headless EABI, VFP, SoftFP ABI, Little Endian"
  elif [ "${SYNO_CPU_ARCH}" == "i686" ]; then
    JAVA_BINARY="ejre-1_6_0_38-fcs-b05-linux-i586-headless-13_nov_2012.tar.gz"
    JAVA_BUILD="x86 Linux Small Footprint - Headless"
  elif [ "${SYNO_CPU_ARCH}" == "ppc" ]; then
    JAVA_BINARY="ejre-1_6_0_38-fcs-b05-linux-ppc-e500v2-headless-13_nov_2012.tar.gz"
    JAVA_BUILD="Power Architecture Linux - Headless - e500v2 core"
  fi    

elif [ "${SYNOPKG_PKGNAME}" == "java7" ]; then
  DOWNLOAD_URL="http://tinyurl.com/javaembed"
  EXTRACTED_FOLDER="ejre1.7.0_60"
  if [ "${SYNO_CPU_ARCH}" == "armv5tel" ]; then
    JAVA_BINARY="ejre-7u60-fcs-b19-linux-arm-sflt-headless-07_may_2014.tar.gz"
    JAVA_BUILD="ARMv5 Linux - Headless EABI, SoftFP ABI, Little Endian"
  elif [ "${SYNO_CPU_ARCH}" == "armv7l" ]; then
    JAVA_BINARY="ejre-7u60-fcs-b19-linux-arm-vfp-sflt-client_headless-07_may_2014.tar.gz"
    JAVA_BUILD="ARMv6/7 Linux - Headless - Client Compiler EABI, VFP, SoftFP ABI, Little Endian"
  elif [ "${SYNO_CPU_ARCH}" == "armv7l-neon" ]; then
    JAVA_BINARY="ejre-7u60-fcs-b19-linux-arm-vfp-hflt-client_headless-07_may_2014.tar.gz"
    JAVA_BUILD="ARMv6/7 Linux - Headless - Client Compiler EABI, VFP, HardFP ABI, Little Endian"
  elif [ "${SYNO_CPU_ARCH}" == "i686" ]; then
    JAVA_BINARY="ejre-7u60-fcs-b19-linux-i586-headless-07_may_2014.tar.gz"
    JAVA_BUILD="x86 Linux Small Footprint - Headless"  
  elif [ "${SYNO_CPU_ARCH}" == "ppc" ]; then
    JAVA_BINARY="ejre-7u60-fcs-b19-linux-ppc-e500v2-headless-07_may_2014.tar.gz"
    JAVA_BUILD="Power Architecture Linux - Headless - e500v2 with double-precision SPE Floating Point Unit"
  fi

elif [ "${SYNOPKG_PKGNAME}" == "java8" ]; then
  DOWNLOAD_URL="http://tinyurl.com/javaembed"
  EXTRACTED_FOLDER="ejdk1.8.0_06"
  if [ "${SYNO_CPU_ARCH}" == "armv5tel" ]; then
    JAVA_BINARY="ejdk-8u6-fcs-b23-linux-arm-sflt-12_jun_2014.tar.gz"
    JAVA_BUILD="ARMv5 Linux - Headless EABI, SoftFP ABI, Little Endian"
  elif [ "${SYNO_CPU_ARCH}" == "armv7l" ]; then
    JAVA_BINARY="ejdk-8u6-fcs-b23-linux-arm-vfp-sflt-12_jun_2014.tar.gz"
    JAVA_BUILD="ARMv6/7 Linux - VFP, SoftFP ABI, Little Endian"
  elif [ "${SYNO_CPU_ARCH}" == "armv7l-neon" ]; then
    JAVA_BINARY="ejdk-8u6-fcs-b23-linux-arm-vfp-hflt-12_jun_2014.tar.gz"
    JAVA_BUILD="ARMv7 Linux - VFP, HardFP ABI, Little Endian"
  elif [ "${SYNO_CPU_ARCH}" == "i686" ]; then
    JAVA_BINARY="ejdk-8u6-fcs-b23-linux-i586-12_jun_2014.tar.gz"
    JAVA_BUILD="x86 Linux Small Footprint - Headless"
  elif [ "${SYNO_CPU_ARCH}" == "ppc" ]; then
    JAVA_BINARY="ejdk-8u6-fcs-b23-linux-ppc-e500v2-12_jun_2014.tar.gz"
    JAVA_BUILD="Power Architecture Linux - Headless - e500v2 with double-precision SPE Floating Point Unit"
  fi
fi

JAVA_BINARY=`echo ${JAVA_BINARY} | cut -f1 -d'.'`
PUBLIC_FOLDER="`cat /usr/syno/etc/smb.conf | sed -r '/\/public$/!d;s/^.*path=(\/volume[0-9]{1,4}\/public).*$/\1/'`"
TEMP_FOLDER="`find / -maxdepth 2 -name '@tmp' | head -n 1`"
NATIVE_BINS_URL="http://packages.pcloadletter.co.uk/downloads/java-native-${SYNO_CPU_ARCH}.tgz"   
NATIVE_BINS_FILE="`echo ${NATIVE_BINS_URL} | sed -r "s%^.*/(.*)%\1%"`"
#DSM versions older than 4.3 need locale support adding, don't download unless needed
[ ! -e /usr/bin/locale ] && INSTALL_FILES="${NATIVE_BINS_URL}"
source /etc/profile


preinst ()
{
  if [ -z ${PUBLIC_FOLDER} ]; then
    echo "A shared folder called 'public' could not be found - note this name is case-sensitive. "
    echo "Please create this using the Shared Folder DSM Control Panel and try again."
    exit 1
  fi

  JAVA_BINARY_FOUND=

  if [ ! -z ${JAVA_HOME} ]; then
    echo "It seems from /etc/profile that a Java Runtime is already installed at ${JAVA_HOME}. Uninstall it and try again."
    exit 1
  fi
  
  [ -f ${PUBLIC_FOLDER}/${JAVA_BINARY}.tar.gz ] && JAVA_BINARY_FOUND=true
  [ -f ${PUBLIC_FOLDER}/${JAVA_BINARY}.tar ] && JAVA_BINARY_FOUND=true
  [ -f ${PUBLIC_FOLDER}/${JAVA_BINARY}.tar.tar ] && JAVA_BINARY_FOUND=true
  [ -f ${PUBLIC_FOLDER}/${JAVA_BINARY}.gz ] && JAVA_BINARY_FOUND=true
  
  if [ -z ${JAVA_BINARY_FOUND} ]; then
    echo "Java binary bundle not found. " > $SYNOPKG_TEMP_LOGFILE
    echo "I was expecting the file ${PUBLIC_FOLDER}/${JAVA_BINARY}.tar.gz. "
    echo "Please agree to the Oracle licence at ${DOWNLOAD_URL}, then download the '${JAVA_BUILD}' package"
    echo "and place it in the 'public' shared folder on your NAS. This download cannot be automated even if "
    echo "displaying a package EULA could potentially cover the legal aspect, because files hosted on Oracle's "
    echo "server are protected by a session cookie requiring a JavaScript enabled browser."
    exit 1
  fi

  cd ${TEMP_FOLDER}
  for WGET_URL in ${INSTALL_FILES}
  do
    WGET_FILENAME="`echo ${WGET_URL} | sed -r "s%^.*/(.*)%\1%"`"
    [ -f ${TEMP_FOLDER}/${WGET_FILENAME} ] && rm ${TEMP_FOLDER}/${WGET_FILENAME}
    wget ${WGET_URL}
    if [[ $? != 0 ]]; then
      if [ -d ${PUBLIC_FOLDER} ] && [ -f ${PUBLIC_FOLDER}/${WGET_FILENAME} ]; then
        cp ${PUBLIC_FOLDER}/${WGET_FILENAME} ${TEMP_FOLDER}
      else     
        echo "There was a problem downloading ${WGET_FILENAME} from the official download link, "
        echo "which was \"${WGET_URL}\" "
        echo "Alternatively, you may download this file manually and place it in the 'public' shared folder. "
        exit 1
      fi
    fi
  done
  
  exit 0
}


postinst ()
{
  WORKING_DIR=`pwd`
  
  #ldd tool is very useful but not included in DSM
  [ ! -e /bin/ldd ] && cp ${SYNOPKG_PKGDEST}/tools/ldd-${SYNO_CPU_ARCH} /bin/ldd

  #DSM versions older than 4.3 need locale support adding
  if [ ! -e /usr/bin/locale ]; then
    #extract native binaries
    cd ${SYNOPKG_PKGDEST}
    tar xzf ${TEMP_FOLDER}/${NATIVE_BINS_FILE} && rm ${TEMP_FOLDER}/${NATIVE_BINS_FILE}

    #build missing locale with UTF-8 support (don't think it matters which language)
    cp ${SYNOPKG_PKGDEST}/bin/* /bin
    cp -R ${SYNOPKG_PKGDEST}/share/i18n /usr/share
    if [ ! -d /usr/lib/locale ]; then
      mkdir /usr/lib/locale
    fi
    localedef -c -f UTF-8 -i en_US en_US.utf8
  fi  

  #extract Java (Web browsers love to interfere with .tar.gz files)
  cd ${PUBLIC_FOLDER}
  if [ -f ${JAVA_BINARY}.tar.gz ]; then
    #Firefox seems to be the only browser that leaves it alone
    tar xzf ${JAVA_BINARY}.tar.gz
  elif [ -f ${JAVA_BINARY}.gz ]; then
    #Chrome
    tar xzf ${JAVA_BINARY}.gz
  elif [ -f ${JAVA_BINARY}.tar ]; then
    #Safari
    tar xf ${JAVA_BINARY}.tar
  elif [ -f ${JAVA_BINARY}.tar.tar ]; then
    #Internet Explorer
    tar xzf ${JAVA_BINARY}.tar.tar
  fi
  
  #install Java
  if [ "${EXTRACTED_FOLDER}" != "${EXTRACTED_FOLDER/jdk/}" ]; then
    mv ${EXTRACTED_FOLDER} ${SYNOPKG_PKGDEST}
    JRE_PATH="`find ${SYNOPKG_PKGDEST}/${EXTRACTED_FOLDER} -name jre`"
  else
    mv ${EXTRACTED_FOLDER} ${SYNOPKG_PKGDEST}/jre
    JRE_PATH="${SYNOPKG_PKGDEST}/jre"
  fi
  
  #change owner of folder tree
  chown -R root:root ${SYNOPKG_PKGDEST}

  echo "NOTE - This package does *not* start and stop like other packages. "
  echo "Java is correctly installed if you can see the runtime and HotSpot version numbers, "
  echo "and locale information in the package Log tab."
  
  exit 0
}


preuninst ()
{
  exit 0
}


postuninst ()
{
  #clean up profile mods
  sed -i "/${COMMENT}/d" /etc/profile
  sed -i "/${COMMENT}/d" /root/.profile

  #leave locale support in place on older DSM versions - too risky to delete system binaries
  
  exit 0
}
 

start-stop-status.sh

#!/bin/sh

JRE_PATH="`find ${SYNOPKG_PKGDEST} -name jre`"
COMMENT="# Synology Java Package"

EnvCheck()
#updates to DSM will reset these changes so check them each startup 
{
  #/etc/profile should contain 5 lines added by this package tagged with trailing comments
  COUNT=`grep -c "$COMMENT$" /etc/profile`
  if [ $COUNT != 5 ]; then

    #remove any existing mods
    sed -i "/${COMMENT}/d" /etc/profile

    #add required environment variables
    echo "PATH=\$PATH:${JRE_PATH}/bin ${COMMENT}" >> /etc/profile
    echo "JAVA_HOME=${JRE_PATH} ${COMMENT}" >> /etc/profile
    echo "CLASSPATH=.:${JRE_PATH}/lib ${COMMENT}" >> /etc/profile
    echo "LANG=en_US.utf8 ${COMMENT}" >> /etc/profile
    echo "export CLASSPATH JAVA_HOME LANG PATH ${COMMENT}" >> /etc/profile
  fi

  #/root/.profile should contain 3 lines added by this package tagged with trailing comments
  COUNT=`grep -c "$COMMENT$" /root/.profile`
  if [ $COUNT != 3 ]; then

    #remove any existing mods
    sed -i "/${COMMENT}/d" /root/.profile

    #add required environment variables
    echo "PATH=\$PATH:${JRE_PATH}/bin ${COMMENT}" >> /root/.profile

    #set the current timezone for Java so that log timestamps are accurate
    #we need to use the modern timezone names so that Java can figure out DST
    #this should be configured in each Java daemon's start script to that changes
    #to timezone settings in DSM are reflected
    #we need to use the modern timezone names so that Java can figure out DST

    SYNO_TZ=`cat /etc/synoinfo.conf | grep timezone | cut -f2 -d'"'`
    SYNO_TZ=`grep "^${SYNO_TZ}" /usr/share/zoneinfo/Timezone/tzname | sed -e "s/^.*= //"`
    echo TZ=\'${SYNO_TZ}\' ${COMMENT} >> /root/.profile
    echo "export PATH TZ ${COMMENT}" >> /root/.profile
  fi
}

case $1 in
  start)
    EnvCheck
    source /etc/profile
    source /root/.profile

    #evidence of whether Java can start successfully is written to the package log
    java -version > ${SYNOPKG_PKGDEST}/output.log 2>&1
    echo >> ${SYNOPKG_PKGDEST}/output.log
    echo System installed locales: >> ${SYNOPKG_PKGDEST}/output.log
    locale -a >> ${SYNOPKG_PKGDEST}/output.log
    echo >> ${SYNOPKG_PKGDEST}/output.log
    echo JAVA_HOME=$JAVA_HOME >> ${SYNOPKG_PKGDEST}/output.log
    echo TZ=$TZ >> ${SYNOPKG_PKGDEST}/output.log

    exit 0
  ;;

  stop)
    exit 0
  ;;

  status)
    source /etc/profile
    source /root/.profile
    if [ -e "${JAVA_HOME}/bin/java" ]; then
      exit 0
    else
      exit 1
    fi
  ;;

  log)
    echo "${SYNOPKG_PKGDEST}/output.log"
    exit 0
  ;;

esac
 

Changelog:

  • 0027 Updated Java 8 to 8u6m, added support for Mindspeed Comcerto 2000 CPU in DS414j for Java 7 and Java 8
  • 0026 DSM updates will no longer break Java
  • 0025 Updated to Java 7u60
  • 0024 Updated to Java 7u55
  • 0023 Added Java 8 support
  • 0022 Updated to Java 7u51
  • 0021 Locale support is no longer downloaded and added to DSM 4.3 or newer since it’s already present
  • 0020 Added support for Intel Atom Evansport and Armada XP CPUs in new DSx14 products, removed Early Access JDK 8 support since it did not run on the Armada SoCs
  • 0019 Updated to Java 7u45
  • 0018 Updated to Java 7u40, and JDK8 Early Access b106
  • 0017 For Armada370 CPU changed from ARMv7 Server JVM to Client JVM since the Server one turned out to be unstable. Added support for Early Access JDK 8 for Armada 370.
  • 0016 Added Armada370 CPU support (DS213j)
  • 0015 Updated to Java 7u21, Java 6 Embedded seems to be no longer maintained by Oracle
  • 0014 Fixed metadata for DSM 4.2 Package Center
  • 013 Updated to Java 6u38 and Java 7u10
  • 012 Installer script fetches native binaries separately to reduce bandwidth on repo hosting
  • 011 Added support for Freescale QorIQ PowerPC CPUs used in some Synology x13 series products, PowerQUICC PowerPC processors in previous Synology generations with older glibc versions are not supported
  • 010 updated to Java 6u34 and Java 7u6
  • 009 corrected timezone bug for Atlantic and Pacific timezones which may have caused error messages when in fact the package had installed correctly
  • 008 unified the build scripts
  • 007 included the locale binaries to simplify installation, fixed environment variables for root user (inc. timezone with DST support), displayed Java version information and env vars in Log tab, incremented Java to latest versions 6u32 and 7u4, fixed detection of renamed .tar.gz archives downloaded by Google Chrome
  • 006 fixed path issue for root user on non-bootstrapped systems, updated info link to refer back to this page, and improved description text
  • 005 incremented JRE versions to match new releases from Oracle
  • 004 forced check for existence of ‘public’ shared folder
  • 003 fixed a stupid typo that stopped 002 from working :)
  • 002 rewrote scripts to be easier to maintain, and to allow for web browsers that untar or rename the Java and toolchain binary bundles as they’re saved
  • 001 fixed package repo support, defined as a non-runnable service, prevented more than one JRE being installed, saved files into actual package folder rather than @appstore/java now that package names can be separate from Package Center display names
  • v3 initial spk release (I think!)
 
 
About these ads

768 thoughts on “Java SE Embedded package for Synology NAS

  1. Tod

    Hi there Patters

    I have run the above and now have Java on my box… does this mean that I can install Serviio as a package now, and actaully have a really decent DNLA server running on my synology box?

    Cheers

    Tod

    Reply
    1. patters Post author

      Hi Tod, yes that’s the idea. I’ve built a package for Serviio 0.6 but I need to wait for it to come out of beta before I can release it into the wild. It shouldn’t be long now though…

      Reply
  2. moelholm

    This is fantastic!!!!! Superb :)

    ( I am a Java nerd )

    Just installed it on my DS211+ with success. Quickly followed by running Tomcat 7.

    It works :)

    /moelholm

    Reply
  3. Peter

    Fantastico!!! Many thanks for this Synology Package!
    I think it should become a part of the default package of the DSM, because Java could be so useful for so many different tasks and apps.

    Reply
  4. Monkeybrain

    Excellent! Thank you soo much, this made my day as I was trying to figure out how to install Java on my DS211j to run a MineCraft server. Now it’s a breeze :-D

    Reply
    1. patters Post author

      Just been having a look at Minecraft. Looks intriguing. Did you manage to get a server running on your syno? Apparently it needs 1GB of RAM…

      Reply
  5. Alex

    Hello
    I get this error, do anyone know why?

    Home> java
    Error: dl failure on line 875
    Error: failed /volume1/@appstore/java/lib/i386/client/libjvm.so, because /volume1/@appstore/java/lib/i386/client/libjvm.so: cannot handle TLS data
    Home>

    Reply
  6. Andrew

    keep getting a failed to install package.
    trying to install on a DS1511+ DSM 3.2
    created a public folder gave full read write access.

    downloaded your java package for intel into it.
    :java1.7.0_x86_v3.spk

    downloaded java se embeded for intel into it
    :ejre-7-fcs-b147-linux-i586-headless-27_jun_2011.tar”

    download synology dsm 3.1 toolchain into it
    :gcc420_glibc236_pineview

    error:
    I was expecting the file ${JAVA_PICKUP}/ejre-7-fcs-b147-linux-i586-headless-27_jun_2011.tar.gz. ”

    any idea thanks.

    Reply
    1. patters Post author

      Sorry for the huge delay responding – your comment got buried and I only properly reviewed it just now. Looks like your browser is automatically ungzipping the file as it downloads. Since this is a common problem I have improved the script to accept either tar, or tar.gz, or even .tar.tar (which Internet Explorer produces).

      Reply
  7. Mike

    Hi,
    I’ve been pondering for ages wether to install serviio on my DS211+ and was so happy when serviio 0.6 came out a few days ago to simplify the process as I’m not that technical.

    However, it looks as if I’m failing on the first step. Unsure of the exact sequence but when I try to install the ‘java.7.0_88f6281_v3.spk’ package from the DSM Package Update/Install, which is all acknowledged ok but returns the following error message when I apply this update :-

    “java binary bundle not found – I was expecting the file /ejre-7-fcs–b147-linux-arm-sflt-headless-27_jun_2011.tar.gz. Please register and download from Oracle etc.”

    I do this but the dowloaded file above (which ends in .tar & not tar.gz) is zipped up and when I try to install this I get an “Invalid File Format” error message! I’ve tried unzipping but there are many files and this is as far as I can get.

    Hopefully you will be able to help – if the answer is not too technical?
    Thanks,
    Mike

    Reply
    1. patters Post author

      You’re probably using Safari to download, which automatically gunzips the files. Try this in a Terminal window:
      cd ~/Downloads
      gzip ejre-7-fcs–b147-linux-arm-sflt-headless-27_jun_2011.tar

      Then try installing the spk package again.

      Reply
  8. Mike

    Hi,
    Thanks for your help, I noticed I had winRAR installed on my PC which was zipping it, so I have uninstalled this and downloaded again from the ‘registered’ link on the oracle web site and saved it directly to the public network drive on NAS using IE8 (On a Vista SP2 Platform) and it now saves it as a unrecongised file (maybe the original file) with the following name;

    ejre-7-fcs-b147-linux-arm-sflt-headless-27_jun_2011.tar.tar

    Unsure why double tar at the end, but unfortunatley it returns an invalid file format error message!
    I have tried it with only one .tar and wondered if it’s just a matter of changing the file extension name! (Tried .spk but didn’t work) I have also tried the Java 6 Embedded version too but with same error results!

    I have also downloaded the file using a Windows 7 PC (Using IE9) and have the exactly the same file name/extension.

    My DS211+ is on DSM Version 3.2-1922.

    Your serviio (0.6) & java (7.0) packages seem to be acknowkedged ok and it’s just getting the embedded java on that is my problem – I think!

    I did try the terminal window (by the run then cmd – if this is correct as I’m not technical) but it returned an error message!

    Sorry to be a pain but hope you can help?

    Thanks,
    Mike

    Reply
    1. patters Post author

      Get the file ending in .tar.tar and just rename it to end with .tar.gz. Don’t do anything else to it. Leave it in the public shared folder. Then install my Java spk package file in Package Center in DSM. Should work then.

      Reply
      1. Mike

        Hi,
        Many thanks, both java and serviio packages are up and running now after I changed the file names.
        Kind regards,
        Mike

  9. Jason

    The Oracle version 6 for x86 is later than the one the package installer expects. Where do you get your version (14 april) ?

    Reply
    1. patters Post author

      Well spotted – I had used an older Oracle download link from my email without checking. Sorry – the Java 6 packages are both updated now.
      It was a test – you passed :) Can you let me know whether it works ok on Intel? Thanks.

      Reply
      1. Jason

        Thanks for the update. Both packages installed and serviio package info now says it’s running. Next job is to get a win7 serviio console to connect (first time using serviio).

  10. Marck

    I have successfully installed 0.6 on my DS 211+ (Marvell Kirkwood mv6282 1.6Ghz) with Java 7 using the above packages.

    The only problem that I have is that Java uses more than 95% of the CPU. This problem is already going on for a few days.

    Has anyone seen this issue before?

    How can I solve this issue?

    Reply
    1. patters Post author

      Have a look at the Serviio log. Is it still adding things to the library? Head over to the Serviio forums to find out how you can increase the log detail level. You’ll find the config file location in my blog post about the Serviio package (you’ll need to stop Serviio, make an edit to the logging config, then restart it).

      Reply
  11. Marck

    Dear Patters,

    I have enabled detailed logging. And indeed Serviio is adding pictures to the library. This explains the high CPU and mem usage.

    Apologies for this basic question, I should have come up with this explanation myself.

    But I just couldn’t explain that Java is actually using the CPU and mem that much

    Reply
    1. patters Post author

      Sorry, I don’t. Did you try installing the full Java SE from Oracle, rather than the Embedded version (since that system is pretty well equipped)?

      Reply
  12. jim

    I’m obviously doing something wrong. I understand that I need to install the Java package first, but I can’t get the installer to load the package. Can you detail the steps I need to follow again.

    I’m running DS207+ w/ OS ver 3.1

    thanks, jim

    Reply
    1. patters Post author

      Hi, yes I’d like to get a repository working since I now maintain several packages, but it needs me to code a small web service. I have done some packet captures so I know what I need to do – the trouble is finding time…

      Reply
  13. Gavin

    Hi, I’ve just tried installing the java package as instructed. It appears to install fine, but when I open the “installed” tab, there’s no option to run the package (as instructed by the installer). Not sure if this is required or not. If I look at /volume1/@appstore/java6, it is just empty except for a marker file containing the text “placeholder”. Any ideas why this hasn’t installed successfully?

    Reply
    1. patters Post author

      Java doesn’t need to start. That’s the Synology Package Center putting up a superfluous message. You can test whether Java is installed by running:
      java -version

      As for the java6 folder being empty, did you install this today? Or yesterday? Until version 002, the package would actually put all the files in @appstore/java, regardless of whether it was java6 or java7. I changed that yesterday and now the files are installed in a jre subfolder inside the package’s proper folder (java6 in your case).

      I would recommend that you install via the package repo though, that way you’ll get notified when new versions are available.

      Reply
  14. Gavin

    Thanks for the quick reply. I installed this today. The version of DSM is 3.2. I did try java -version, but it was not recognised. Tried restarting the synology box too. Checked /etc/profile and presumed the path in there was updated by the package installer. Here’re the additional entries in profile:

    PATH=/opt/bin:/opt/sbin:$PATH
    PATH=$PATH:/volume1/@appstore/java6/jre/bin
    JAVA_HOME=/volume1/@appstore/java6/jre
    LANG=en_US.utf8
    export JAVA_HOME LANG PATH

    and here are the contents of the java6 folder:

    DiskStation> pwd
    /volume1/@appstore/java6
    DiskStation> ls -al
    total 12
    drwxr-xr-x 2 root root 4096 2011-11-20 18:03 .
    drwxr-xr-x 3 root root 4096 2011-11-20 18:03 ..
    -rw-r–r– 1 root root 12 2011-08-23 02:02 marker
    DiskStation> java -version
    -sh: java: not found

    Do you mean you recommend downloading your package and manually installing it?

    Reply
    1. patters Post author

      Hi, path is fine – something must have gone wrong extracting the archive containing java. It could be a typo from when I rewrote the scripts yesterday. I tested the ARM packages so I’m guessing you’re on Intel perhaps?

      Can you also check the file extension of the java archive you put in /volume1/public – is it .tar or .tar.gz?

      My script runs ‘tar xvf’ if it’s .tar and ‘tar xvfz’ if it’s .tar.gz

      It could be that your web browser mangled the name to .tar but didn’t actually ungzip it. If so I need to know which browser so I can test…

      Reply
      1. Gavin

        Hi, there was some weirdness, the downloaded files (and those in the public folder) had the following extensions:

        ejre-1_6_0_27-fcs-b07-linux-i586-headless-18_jul_2011.tar
        ejre-1_6_0_27-fcs-b07-linux-i586-headless-18_jul_2011.tar.gz.download
        gcc420_glibc236_pineview.tar
        gcc420_glibc236_pineview.tgz.download

        although from what you say above, the .tar versions of these should have been fine?

        I removed all of these and extracted the tar.gz from the .download files and ran the installer again. I can confirm that the files were extracted successfully, I can see these in the public folder, but there are still no files installed in the /volume1/@appstore/java6 directory.

        I downloaded the files on osx using safari.

      2. patters Post author

        I’ll look into it. Btw, .download on Mac OS Safari is usually a partially downloaded file. But yes, Safari does normally gunzip files without asking, which explains the .tar ones. I checked the scripts again for intel – file names all look fine.

        Did the toolchain stuff work? Can you run the ‘locale’ command?

      3. Gavin

        Hi, the toolchain folder did get extracted into the public folder, and I could run locale successfully. Cheers.

  15. Joakim

    Hello,

    i have just reinstalled my DS211+ from the factory settings and with DSM 3.2.

    i installed Java 6 trough your guides and it worked fin!

    But, wen java susscessfolly was installed a text says that i can start java from package center. But there is no Start button, just uninstall button?!

    Is there any service i need to start first?

    Reply
    1. patters Post author

      No that’s normal. There’s nothing that needs to ‘start’ for Java, it’s not a service/daemon. Even though I’ve defined it as a package that is not startable, that message comes up. Just ignore, it’s Package Center being a little stupid. The real test is if you open a terminal session and run:
      java -version

      You should see something like this:
      java version “1.6.0_27″
      Java(TM) 2 Runtime Environment, Standard Edition for Embedded (build 1.6.0_27-b07, headless)
      Java HotSpot(TM) Client VM (build 20.2-b06, mixed mode)

      Reply
  16. Joakim

    Now i have fix it!

    i used safari to download the java 6.
    but i read her on the press that it could unzip the gz file.
    so i tryed to dowload with google chrome and then it worked!

    Many Thx!

    Reply
  17. Phil Wade

    Hi Patters,
    I have tried following the instructions and can see the Serviio, Java embedded 6 & 7 in my Package Centre. However when I try to install the Java Embedded I get an error, telling me it expects to find a file in the public folder, go register with Oracle to download it!! I thought this was what was contained in in the package from you and did not anticipate having to download additional files or register with Oracle. Do I have to download something else prior?? I have DSM 3.2 on a DS110J. Am I missing something here??
    Cheers,
    Phil

    Reply
    1. patters Post author

      Re-read the blog post :)
      The whole reason no one had made a package is that Java cannot be redistributed under the terms of its licence. So you have to sign up with Oracle yourself and get the download, then my package does the rest.

      Reply
      1. Phil

        Hi Patters,
        Eventually located and downloaded all the additional files flagged by your install error messages and then lauched your packages. All went well and now Serviio is up and running, partially at least, as for some reason I can not get photos or videos to be recognised, but music is streaming to my Sony TV and Bluray. I’ve entered the location of the public files /Volume1/photo etc. and ticked all the right boxes on the Serviio interface, but no joy as yet. Any suggestions before I take another look at the weekend? Guesss I also need to search on the Serviio forum.
        Anyway – great job with your packages – thanks.

      2. patters Post author

        Thanks. By the way, remember that Linux paths are case sensitive. It’s /volume1 not /Volume1. Could that be your problem perhaps?

  18. Chris

    Hi

    I am trying to make a minecraft server and I have installed java following your instructions, the next part of the instalation requires me to know where the ejrel.6.0_21 folder is, but I can not find it. any suggestions?

    here is what i am supposed to run

    ejre1.6.0 21/bin/java -Xmx256m -jar minecraft server.jar net.minecraf
    t.server.MinecraftServer nogui

    Reply
    1. patters Post author

      You don’t need the full path, you can run java just by typing ‘java’.

      If you want to go looking, you’ll find it in /volume1/@appstore/java6/jre/bin

      Reply
  19. Rde

    Hi,

    Any chance you could make a package for the Freescale PPC Processor ?
    Java 6 seems to be available for my Ds410 (ejre-1_6_0_27-fcs-b07-linux-ppc-e500v2-headless-18_jul_2011.tar)

    Reply
    1. patters Post author

      Hi, though the Java build for the PPC e500 CPU exists, it’s compiled against a newer version of glibc than the Synology software so it won’t work unfortunately.

      Reply
  20. Phil Wade

    Hi Patters,
    My path to the media folders is in lower case [/volume1/photo..]. HoweverI have another query. When I click on the “library refresh” button, why does the pop-up window show “To Do…” – what does that mean? By the way my photos now seem to be partially displaying on My TV, but still no videos!
    Cheers Phil W.

    Reply
    1. patters Post author

      I don’t think photo support is that good really – I once added my iPhoto library and it took hours to index and crashed. If you leave out the photos for now, you should find that the videos are added fine. As for the ‘To do’ that’s a progress feature that wasn’t yet implemented in the Web UI I integrated.

      Reply
  21. grindal

    i”ve managed to install the Jave 6 or 7 version, but it mentioned
    status “STOPPED”, how do i get this up and running ?

    Reply
  22. Michael Taylor

    Hi, I am trying to install on Synology DS712+ box. I cannot find the file ejre-1_6_0_27-fcs-b07-linux-i586-headless-18_jul_2011.tar.gz from Oracle anymore. Is it possible you could update your installer to be a bit more loose on the filename? I have build 30 from nov 2011.

    I’ve repacked it with the old filename and the old path in the tarball as a workaround, but I want to make sure I can use the package center to update later.

    Thanks,

    Mike

    Reply
    1. patters Post author

      Unfortunately I can’t really do fuzzy name detection because then the package version numbering wouldn’t be consistent, which has a knock-on effect on update notifications via the repo. They only increment the versions every few months so a manual update is acceptable. I don’t tend to realize until it gets reported here though, so thanks.

      Reply
  23. Paul

    Hej Patters,

    I’m having some problems installing Java on my DS211 (DSM 3.2) I’ve registered and downloaded the latest Java 7 SE (ejre-7u2-fcs-b13-linux-arm-sflt-headless-22_nov_2011.tar.gz) and put it in the /volume1/public directory, however when I use the package installation manager, it tells me that it’s expecting a different file (ejre-1_6_0_27-fcs-b07-linux-arm-sflt-eabi-headless-18_jul_2011.tar.gz) and won’t continue.

    I assume that I’m just being a bit thick about this, but will it work if I just rename the first file name to be the file it’s expecting and go from there ? Or am I somehow downloading the wrong version ?

    Reply
    1. patters Post author

      You’re absolutely right to point this out. I’ve updated the packages on the repository. Oracle release new builds now and again and I have to rebuild the packages.

      Reply
  24. Max McCall

    Hello patters

    I have just read last night’s post from Paul, a fellow poster who appeared to be having a similar difficulty to myself. I followed your advice to him and everything is sorted out with both Java 7 and Serviiio.

    I must thank you both very much

    Reply
    1. patters Post author

      Hi Max, I hadn’t replied to your inquiry because I was still wondering what the problem could have been (your comment suggested the Java package had installed successfully, but that it was Serviio that was failing). Anyway, glad you got it working!

      Reply
      1. Max McCall

        Hello again Patters, like Paul I had downloaded the latest files and when they would not allow installation, I manually re-named the files (Changed the date) this appeared to permit the installation of Java 7 but would not allow the installation of Serviio. I feel a bit of an idiot now.

  25. Bart

    Please help, I can’t install the spk, the error message is:

    This package is not supported on the platform of diskstation

    I have a DS107+.

    Reply
  26. Sandra

    Hi, I tried JAVA 7 and JAVA 6. I could install both of them, but could not “start” them. If I click on “more” I see “stopped”.

    The “protocol” is empty. What can I do now? I own a DS710+.

    Reply
    1. patters Post author

      As I’ve answered several times here, there is nothing to start for Java. The message that comes up is just the Package Center assuming wrongly. If you launch a terminal connection to your syno and type:
      java -version

      you should see that it’s installed.

      Reply
  27. Andres

    I tried to read all messages, I found nothing about the new toolchain for DSM 3.2. It seems that the file is named gcc421_glibc25_88f6281-GPL. The 3.1 toolchain is gcc421_glibc25_88f628x.tgz

    1) I sit important, since I have DSM 3.2, to use the “right” toolchain ?
    2) Can I use the new one with your package installation ?
    3) VCAn it work if I change the filename ?

    Thanks,

    Reply
    1. patters Post author

      For now it still asks for the 3.1 toolchain. You can see that the gcc and glibc versions are unchanged so I don’t think it’s important. It still works if your NAS is on 3.2. I’m not sure how the directories are laid out in the 3.2 toolchain so best not to use that just yet. It may work, it may not. I think I’ll probably change the package to use 3.2 with the next version, however it seems a bit pointless to deliberately exclude systems on DSM 3.1 for no good reason.

      Reply
  28. John

    Can’t seem to get this installed on a Synology DS109+ with DSM 3.2 The only package I see is OpenRemote.

    Any ideas?

    Reply
  29. Eli Simpson

    Installed Java 6 and Serviio and it seems to be working but I’m not getting UTF-8 characters in filenames (specifically Japanese characters). Is there any way to trouble UTF-8 support? I ran the “locale” command in a terminal and got the following:

    LANG=en_US.utf8
    LC_CTYPE=”en_US.utf8″
    LC_NUMERIC=”en_US.utf8″
    LC_TIME=”en_US.utf8″
    LC_COLLATE=”en_US.utf8″
    LC_MONETARY=”en_US.utf8″
    LC_MESSAGES=”en_US.utf8″
    LC_PAPER=”en_US.utf8″
    LC_NAME=”en_US.utf8″
    LC_ADDRESS=”en_US.utf8″
    LC_TELEPHONE=”en_US.utf8″
    LC_MEASUREMENT=”en_US.utf8″
    LC_IDENTIFICATION=”en_US.utf8″
    LC_ALL=

    Reply
  30. Eli Simpson

    That utility was able to read the names, although they don’t print out correctly in PuTTY (which maybe is expected?) Hope there’s some way to get it working as I have lots of files with UTF8 filenames.

    Reply
  31. Aidan

    I managed to get Java installed OK. I want to use it with crashplan however I get the following error

    nice: /volume1/@appstore/java7/jre/bin: Permission denied

    Anyone know how I fix this permission error?

    Reply
  32. JM

    Not sure if anyone would be able to help me, but I installed Java SE 6 successfully on my DS111. I also was able to successfully install Apache Tomcat 6. However, I am having some problems with tomcat.

    When I SSH (using PUTTY) into the synology and start tomcat manually everything works; however, when I log out the tomcat server stops working.

    Do I need to create a startup script from tomcat or set a variable within java? (I’m not sure if I can do either without help.) Thanks if anyone is able to help.

    Reply
    1. patters Post author

      I found that confusing too, as I wasn’t used to Linux. When you invoke processes from a shell, and that shell later dies (by logging out), those running processes also die with it. So yes, you’ll need to create a daemon script for Tomcat server. Take a look at my method here from before I had built the Serviio package:

      http://pcloadletter.co.uk/2011/08/02/serviio-0-6-on-synology-nas/

      To jump to the right section search for the text “In the DSM User Control Panel create a new user called serviio”

      It’s good practice to run daemons as a user account other than root, granting it only privileges that may be necessary (such as chown -R on your Tomcat folder).

      Reply
      1. JM

        Thanks patters,

        The script worked great!
        The only difference is I needed to put it in the /usr/syno/etc/rc.d folder for it to startup when I restarted my NAS. Other than that it was smooth sailing.

    1. patters Post author

      I’m afraid not – the PowerPC synos can’t run the Oracle JRE (even though it exists) because their DSM uses an old version of glibc.

      Reply
  33. gothax2a

    Hello,
    Thx for your job
    I have one question :
    My Synonoly is DS411slim with Marvell Kirkwood mv6282 so ARMv6 ! Is it easy to obtain from your site with your kwonledge a spk like this :
    Java 6 for Marvell Kirkwood CPU (ARMv 6 ): java1.6.0_30-88f6282-005.spk ??? so for ARMv6 ?

    Thx a lot

    just one precision : i can install java ARMv5 with Oracle Java for ARMv5 on my 411Slim but when i start it the CPU is at 100%

    Reply
  34. Strongberry

    OMG The 6th version works like a charm!! Thank you so mutch, Synology definitely needs to integrate that as a genuine package!
    No chances with the 7th though…
    I have a DS211j btw…

    Reply
  35. Pingback: Synology and Java | Tigar

      1. preddan

        Hi.

        I got this same problem today with Java 6.
        Coud you please see whats up?

        Thanx for all you work!

      2. patters Post author

        I have just checked again, the package definitely downloads and installs from the repo fine. Are you located in a country that cannot access Dropbox perhaps (dunno, China might block that for instance)?
        I don’t understand – are you saying you can’t find ejre-1_6_0_30-fcs-b12-linux-arm-sflt-eabi-headless-10_nov_2011.tar.gz?

      3. preddan

        I downloaded the file from oracle no problem, and then the DSM 3.1 toolchain. When I click Install on Java 6 it says (next to the install button): “Java SE for embedded 6: broken” and then I get the box with “Failed to download”.

        However

        I tried downloading the 7 one from oracle and install Java 7 and that one worked.

  36. Fraggle

    How can I install sun-java6-jre sun-java6-plugin sun-java6-fonts screen on the synology?
    It is good to use for running bukkit for minecraft servers to start in virtual windows so that I can close putty after starting bukkit server.

    Thanks for your help.

    Reply
  37. Hubert

    I want to download your package “Java 6 for Marvell Kirkwood CPU (ARMv5)” directly because I am on DSM 3.1 but can’t find your Dropbox folder. Is it somewhere else now? Thanks for responding.

    Reply
      1. Michael

        Hi,

        you write here, that u think everyone uses dsm 3.2 now. So do i, but what can i do to run java on ds411 with 88FR131 proc?
        Sorry, but i didn’t get it. Is it possible to use your scripts for 88f6281 ? Or did your know some other way?
        Thx.

      2. Michael

        Thx for your fast reply – but thats strange:

        i found this site:

        http://www.synology-wiki.de/index.php/Welchen_Prozessortyp_besitzt_mein_System%3F

        and
        cat /proc/cpuinfo
        says:
        Processor: Feroceron 88FR131 rev 1 (v51)

        So the german wiki-site links your english-site but has this particular difference in MY cpu. Any idea?

        Well i think i’ll give it a try. As far as i understand i can use your script and i just have to rename the toolchain 3.2 files to the name in your script for toolchain 3.1 ?

      3. patters Post author

        Strange. When I run cat /proc/cpuinfo I also get that result with my DS111. Maybe it’s another name for the 88f6282. It does also report this further down the output:
        Hardware : Synology 6282 board

        And, no – just use the 3.1 toolchain, that’s what the package expects. I don’t think it’s very different from 3.2 (gcc and glibc versions are the same).
        Since your CPU is supported, I’d recommend you use the repo.

      4. Michael

        thx – it worked with all of your described files. My “special” CPU makes no problem.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s