There are two ways to install java chaincode:
source code
jar package
Source code installation chain code method:
The installation is carried out in the javaenv container, which is extremely slow, and the build takes a particularly long time.
1. Build the jar package
We can use maven or grandle in idea for packaging.
I use maven as an example:
After running, you can see:
This is our chaincode package
Note:
This chaincode package only saves the java chaincode, and does not save files such as indexes and private data collections.
So if you need to use indexes and private data, etc., save them together with the chaincode package in a folder, and use the peer lifecycle chaincode package to package them
After that, the peer node will install the chain code (peer lifecycle install) very quickly.
2. View the packaged files
Unzip the packed file
Check out the directories in it:
code.tar.gz: chain code and other data
metadata.json: Some information about the chaincode, such as lang, chaincode package path, label, etc.
Then unzip code.tar.gz and check the directory:
META-INF: index
src: chaincode and private data collection packaged in maven
If the source code is compiled here, the decompressed output is not chaincode.jar, but the source code.