# Java SDK for Hyperledger Fabric 1.3
Welcome to Java SDK for Hyperledger project. The SDK helps facilitate Java applications to manage the lifecycle of
Hyperledger channels and user chaincode. The SDK also provides a means to execute
user chaincode, query blocks
and transactions on the channel, and monitor events on the channel.
The SDK acts on behave of a particular User which is defined by the embedding application through the implementation
of the SDK's `User` interface.
Note, the SDK does ***not*** provide a means of persistence
for the application defined channels and user artifacts on the client. This is left for the embedding application to best manage.
Channels may be serialized via Java serialization in the context of a client.
Channels deserialized are not in an initialized state.
Applications need to handle migration of serialized files between versions.
The SDK also provides a client for Hyperledger's certificate authority. The SDK is however not dependent on this
particular implementation of a certificate authority. Other Certificate authority's maybe used by implementing the
SDK's `Enrollment` interface.
This provides a summary of steps required to get you started with building and using the Java SDK.
Please note that this is not the API documentation or a tutorial for the SDK, this will
only help you familiarize to get started with the SDK if you are new in this domain.
## Release notes
|Release | Notes |Summary|
|--------|:------|:------|
|1.3 | [v1.3 release notes](./docs/release_v1.3.0_notes.md)|<ul><li>Java chaincode support</li><li>Query chaincode collection configuration</li><li>Identity Mixer transaction unlinkabilty support</li></ul> |
|1.2 | [v1.2 release notes](./docs/release_v1.2.0_notes.md)|<ul><li>Private data collection support</li><li>Service discovery</li><li>Fabric CA certificate API </ul>|
|1.1 | [v1.1 release notes](./docs/release_v1.1.0_notes.md)|<ul><li>Channel service events</li><li>FilterBlocks</li><li>JCA/JCE compliance</li><li>Chaincode events</li><li>Node chaincode</li></ul>|
## Checkout SDK from Github
```
git clone https://github.com/hyperledger/fabric-sdk-java.git
cd fabric-sdk-java/
git checkout -b release-1.3
```
## Java applications
For Java applications use the latest published v1.3.x releases:
```
<!-- https://mvnrepository.com/artifact/org.hyperledger.fabric-sdk-java/fabric-sdk-java -->
<dependency>
<groupId>org.hyperledger.fabric-sdk-java</groupId>
<artifactId>fabric-sdk-java</artifactId>
<version>1.3.0/version>
</dependency>
```
## Known limitations and restrictions
* TCerts are not supported: JIRA FAB-1401
* HSM not supported. JIRA FAB-3137
<p />
<p />
`*************************************************`
## Latest Fabric Builds.
Latest Fabric builds are seldom needed except for those working on the very latest Fabric features.
Some information to help with that can been found in [Developer Instructions](./docs/DeveloperInstructions.md)
## Latest builds of Fabric and Fabric-ca v1.3.0
To get a functioning Fabric v1.3.0 network needed by the SDK Integration tests once it's built.
In the directory `src/test/fixture/sdkintegration` issue :
`./fabric.sh restart`
This command needs to be rerun each time the Integration tests are run.
### Setting Up Eclipse
To get started using the Fabric Java SDK with Eclipse, refer to the instructions at: ./docs/EclipseSetup.md
## SDK dependencies
SDK depends on few third party libraries that must be included in your classpath when using the JAR file. To get a list of dependencies, refer to pom.xml file or run
<code>mvn dependency:tree</code> or <code>mvn dependency:list</code>.
Alternatively, <code> mvn dependency:analyze-report </code> will produce a report in HTML format in target directory listing all the dependencies in a more readable format.
To build this project, the following dependencies must be met
* JDK 1.8 or above
* Apache Maven 3.5.0
To run the integration tests Fabric and Fabric CA is needed which require
* Docker 18.03
* Docker compose 1.21.2
## Using the SDK
### Compiling
Once your JAVA_HOME points to your installation of JDK 1.8 (or above) and JAVA_HOME/bin and Apache maven are in your PATH, issue the following command to build the jar file:
<code>
mvn install
</code>
or
<code>
mvn install -DskipTests
</code> if you don't want to run the unit tests
### Running the unit tests
To run the unit tests, please use <code>mvn install</code> which will run the unit tests and build the jar file.
**Many unit tests will test failure condition's resulting in exceptions and stack traces being displayed. This is not an indication of failure!**
**[INFO] BUILD SUCCESS** **_At the end is usually a very reliable indication that all tests have passed successfully!_**
### Running the integration tests
You must be running local instances of Fabric-ca, Fabric peers, and Fabric orderers to be able to run the integration tests. See above for for how to get a Fabric network running.
Use this `maven` command to run the integration tests:
* _mvn clean install -DskipITs=false -Dmaven.test.failure.ignore=false javadoc:javadoc_
### End to end test scenario
Following the below integration tests/example code shows almost all that the SDK can do.
To learn the SDK you must have some understanding first of Fabric Hyperledger. Then it's best to study the integrations tests and better yet work with them in a debugger to follow the code ( *a live demo* ).
Start first with End2endIT.java and then End2endAndBackAgainIT.java samples before exploring the other samples.
Then once you understand them you can cut and paste from there to your own application. ( _the code is done for you!_ )
**Note** These samples are for testing, validating your environment and showing how to use the APIs. Most show a **simple** balance transfer.
**They are not meant to represent best practices in design or use of chaincode or the use of the SDK**.
|Integration Test | Summary and notes|
|--------|:------|
|[End2endIT.java](https://github.com/hyperledger/fabric-sdk-java/blob/8044bac1bfe9baf9d6360b067e0d6b5445cc953d/src/test/java/org/hyperledger/fabric/sdkintegration/End2endIT.java)|<ul><li>Register and enroll users with Fabric certificate authority.</li><li>Constructing channel first time.</li><li>Installing chaincode.</li><li>Instantiating chaincode.</li><li>Executing chaincode.</li><li>Querying channel for block information.</li><li>Chaincode event listener</li><li>Traversing block for information.</li><li>Prerequisite for all other testcases.</li></ul> |
|[End2endAndBackAgainIT.java](https://github.com/hyperledger/fabric-sdk-java/blob/8044bac1bfe9baf9d6360b067e0d6b5445cc953d/src/test/java/org/hyperledger/fabric/sdkintegration/End2endAndBackAgainIT.java)| <ul><li>Recreate channel.</li><li>Update chaincode.</li><li>Checking installed and instantiated chaincode.</li></ul> |
|[End2endNodeIT.java](https://github.com/hyperledger/fabric-sdk-java/blob/8044bac1bfe9baf9d6360b067e0d6b5445cc953d/src/test/java/org/hyperledger/fabric/sdkintegration/End2endNodeIT.java)| <ul><li>Shows running End2endIT.java but with Node chaincode.</li><li>Note subclasses En2endIT class.</li></ul> |
|[End2endJavaIT.java](https://github.com/hyperledger/fabric-sdk-java/blob/8044bac1bfe9baf9d6360b067e0d6b5445cc953d/src/test/java/org/hyperledger/fabric/sdkintegration/End2endJavaIT.java)| <ul><li>Shows running End2endIT.java but with Java chaincode.</li><li>Note subclasses En2endIT class.</li></ul> |
|[End2endIdemixIT.java](https://github.com/hyperledger/fabric-sdk-java/blob/8044bac1bfe9baf9d6360b067e0d6b5445cc953d/src/test/java/org/hyperledger/fabric/sdkintegration/End2endIdemixIT.java)| <ul><li>Shows running End2endIT.java but with Idemix credentials.</li><li>Note subclasses En2endIT class.</li></ul> |
|[NetworkConfigIT.java](https://github.com/hyperledger/fabric-sdk-java/blob/8044bac1bfe9baf9d6360b