Java Jar files
Last updated
Last updated
It is highly recommended to build the chaincode inside docker containers with the hyperledger fabric runtime environment images to avoid any conflicts with versions of the programming language and the operating systems. For building java for fabric v2.5, hyperledger/fabric-javaenv:2.5 can be used
Example: Asset Transfer Go Chaincode: https://github.com/spydra-tech/fabric-java-externalcc-sample/tree/main
Make sure to update build.gradle file to include the plugin - com.github.johnrengelman.shadow and add shadowJar section with basename parameter as chaincode. Create manifest section inside shadowJar with attribute: Main-Class with the ContractBootstrap class’s path (refer external chaincode documentation of spydra).
Steps:
Navigate to the root of the java source code
Use the command to build the .jar file “/gradlew build shadowJar -x test” .jar/.jar(s) will be created in the path “build/libs”
Use the command to build the .jar file “/gradlew build shadowJar -x test” .jar will be created in the path “build/libs”
If you want to zip the asset-transfer-basic chaincode, select the chaincode.jar file and zip it. For java, .jar files are expected to be present inside the zip at the root path. (Eg: When opening the zip file on windows, it should not contain another directory, rather the chaincode.jar file should be present)
META-INF folder can also be included in the zip file, select the chaincode.jar file and META-INF folder and zip it.