Category Archives: java

android apk NoClassDefFoundError (gradle build)

My android application is build with gradle and my apk is generated and works correctly.
After some developpement iterations, i include android-support-v4.jar library to ide project and gradle build file like following:

Build with gradle and install apk on avd ==> NoClassDefFoundError (class which extends class located in android-support-v4.jar library)

Solution:

./gradlew clean

And it works again

onSwipe listener without using Swipe Views

1. create SimpleGestureFilter class containing interface SimpleGestureListener

And then, your Activity must implement SimpleGestureListener interface like following

Reference : here

resume android MediaPlayer after pause

To pause MediaPlayer use :

And to resume

profile remote host jboss7 with jprofiler

local machine
– create ssh tunnel : ssh -L 8849:127.0.0.1:8849 remoteuser@remotehost
– launch jprofiler : e.g. /mnt/jprofiler7/bin/jprofiler
– new session -> remote host -> enter host 127.0.0.1 as port 8849 -> save session (don’t start session you must accomplish remote host configuration and restart server before)

remote host (linux x64)
– install(unzip) jprofiler in any folder in remote host file system : e.g. /opt/jprofiler
– edit $JBOSS_HOME/bin/standlaone.sh and add following (this will launch jprofiler agent uppon jboss server. jprofiler agent will listen on port 8849)

– restart jboss server

local machine
– start jprofiler saved session

That’s all

want to handle json in Java : play with javax.json

First get libraries
With maven for example add these two artifacts

Parse json String variable (event processing)

Hibernate exception : cannot simultaneously fetch multiple bags

Problem

Exception class : org.hibernate.loader.MultipleBagFetchException
Exception : cannot simultaneously fetch multiple bags

Solution

Use @LazyCollection(LazyCollectionOption.FALSE) rather than fetch=FetchType.EAGER
Annotation @LazyCollection(LazyCollectionOption.FALSE) makes that collecion is loaded like with FetchType.EAGER and you can use it on two and more collections.

Example

Initial Code : Works with lazy fetch type

Wrong manipulation : wanna set fetch type to eager

Solution : if you want to force loading collection

XSLT java debug

You may need some debug message to be logged in standard output

java debug class

xsl code

Apache POI : delete excel empty rows

POI method sheet.removeRow(), removes row cells but doesn’t clear them from excel output.
Means if you have three rows and you apply sheet.removeRow(1), you will have:
– not changed first row
– empty second row
– not changed third row

So to remove row completly you must then shift rows following.
But for some reason sheet.shiftRows() poi api method doesn’t work for me.
Code bellow do it

Apache POI : delete list of excel columns / keep only list of excel columns

First you must got code from here

Remove some columns with provided headers

Keep only columns with provided headers

Apache POI : remove excel columns

Unfortunatly there was no method to remove excel columns in poi api.
Code bellow (found here) can help