This is an example on how to use the official iota java library (iota.lib.java) together with Maven.
Please make sure you have the JRE (Java Runtime Environment) and Maven installed. Here is how to do that:
Depending on your permissions, you might have to write sudo
in front of each line.
$ apt update
$ add-apt-repository ppa:webupd8team/java
$ apt-get update
$ apt-get install oracle-java8-installer
$ apt-get install -y maven
$ apt-get install oracle-java8-set-default
To check whether the installations went successfully, execute these commands:
$ java -version
$ mvn --version
credits to this guide.
Please install the JRE from oracle.com. You can check whether it works by executing java -version
in your console. After that, proceed to install Maven:
-
download the latest version of Maven from maven.apache.org/download.cgi
-
unzip it into the folder where you want to install Maven (e.g. C:\Program Files\Apache\maven)
-
add both
M2_HOME
andMAVEN_HOME
variables in the Windows system enviroment and point it to the maven folder (C:\Program Files\Apache\maven) -
update the
PATH
variable, append Maven bin folder: %M2_HOME%\bin (now you can run maven commands everywhere) -
to test whether it works, execute
mvn --version
in cmd, this should show you details about the installed version, directory etc.
You need to install the official IOTA java library JOTA (iota.lib.java) locally. There are several ways to do that:
$ cd ~/somewhere-over-the-rainbow/
$ wget https://github.com/iotaledger/iota.lib.java/archive/master.zip
$ unzip master.zip
$ cd iota.lib.java-master
$ mvn install
For this you will need the GIT plugin (installation on UBUNTU via: sudo apt-get install git
)
$ cd ~/somewhere-over-the-rainbow/
$ git clone https://github.com/iotaledger/iota.lib.java
$ cd iota.lib.java
$ mvn install
-
click on
Clone or download
and selectDownload ZIP
-
unzip the downloaded master.zip file
-
open you console (CMD on windows) and
cd
yourself into the directoryiota.lib.java-master/
you just unzipped -
execute
mvn install
to locally install the iota.lib.java repository
Simply create the executable .jar directly from the GitHub source code. Again, there are several ways to do that:
$ cd ~/my-favorite-directory/
$ wget https://github.com/mikrohash/jota-example/archive/master.zip
$ unzip master.zip
$ cd jota-example-master
$ mvn versions:use-latest-versions -DallowSnapshots=true -DexcludeReactor=false
$ mvn install
For this you will need the GIT plugin (installation on UBUNTU via: sudo apt-get install git
)
$ cd ~/my-favorite-directory/
$ git clone https://github.com/mikrohash/jota-example
$ cd jota-example
$ mvn versions:use-latest-versions -DallowSnapshots=true -DexcludeReactor=false
$ mvn install
-
click on
Clone or download
and selectDownload ZIP
-
unzip the downloaded master.zip file
-
open you console (CMD on windows) and
cd
yourself into the directoryjota-example-master/
you just unzipped -
run
mvn versions:use-latest-versions -DallowSnapshots=true -DexcludeReactor=false
to update all dependencies to the newest versions -
execute
mvn install
to locally install the iota.lib.java repository
Simply start the .jar with your JRE:
$ java -jar target/jota-example-[VERSION].jar