First, build the chaincode using gradle build. You should do this from the following folder:
github.com/hyperledger/fabric/core/chaincode/shim/java
Now, from the Example java code folder build it again by gradle -b build.gradle build
This should work