Category: java

  • Play Framework – Activator – Fix for IllegalArgumentException: empty text

    In case of calling an Play Server via HTTPS, an strange Exception is thrown as shown below. i.e. https://localhost:9000/ Fix: just use HTTP without the S 🙂 [error] p.c.s.n.PlayDefaultUpstreamHandler – Exception caught in Netty java.lang.IllegalArgumentException: empty text at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:89) ~[netty-3.10.4.Final.jar:na] at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty-3.10.4.Final.jar:na] at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty-3.10.4.Final.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:191) ~[netty-3.10.4.Final.jar:na] at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:102) ~[netty-3.10.4.Final.jar:na] at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty-3.10.4.Final.jar:na]…

  • Lucene 4 – Getting Started – Demo File Search

    Download Lucene and Index Files # set lucene version version=”4.4.0″ # set base directories basedir=~/build/lucene/lucene-$version indexdir=$basedir/data/index # create direct for Lucene code and binaries mkdir -p $indexdir cd $basedir/.. # download lucene if [ ! -e lucene-$version.zip ]; then wget http://apache.imsam.info/lucene/java/$version/lucene-$version.zip fi; # extract unzip -oq lucene-$version.zip # create directory to save the search index…

  • Linux – Install Eclipse IDE

    The easiest way to install Eclipse in Ubuntu is through the standard repository sudo apt-get install -y eclipse Unfortunately, this install an outdated version. Currently the version 3.8.0 gets installed, although the latest stable version is 4.2.1. The eclipse team does have a Debian PPA as well, ppa:eclipse-team/debian-package. Adding this PPA doesn’t change anything and…

  • Java – Parse Integer and String Lists from Text

    public static List getIdsList(String ids) { ids = StringUtils.stripStart(ids, “{“); ids = StringUtils.stripEnd(ids, “}”); List list = parseInts(ids, ‘,’); return list; } public static List parseInts(String source, char delimeter) { if (StringUtils.isEmpty(source)) { return Collections.emptyList(); } List result = new ArrayList(); for (String intStr : source.split(String.valueOf(delimeter))) { result.add(NumberUtils.toInt(intStr)); } return result; } public static List…

  • Java – Get Exception as String

    public static String exceptionToString(Throwable throwable ) { try{ StringWriter stringWriter = new StringWriter(); throwable.printStackTrace(new PrintWriter(stringWriter)); return stringWriter.toString(); }catch(Exception e){ // shouldn’t happen but whatever return null; } }

  • Java – ByteToHex and CharToHex

    public static String byteToHex(byte b) { // Returns hex String representation of byte b char hexDigit[] = {‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’ }; char[] array = { hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f] }; return new String(array); } public static String charToHex(char…