NEM Development 101 (episode 01 - java, git, maven, nem.core)

This is first of a short series of posts. We will try to show how to create an environment to do AWESOME things :wink:

In this part we’ll deal with prerequisites for further episodes.
The description is step by step, to allow even beginners trying it out.

Java

Let’s start by installing java.

We’ll pick x64 Java Developement Kit (JDK). JDK automatically installs Java Runtime Environment (JRE).

Installation is pretty straightforward, it mostly consist of clicking, next, next, next.

JAVA_HOME

Unfortunatelly java installer won’t set JAVA_HOME environment variable, so we’ll have to do it manually.

Start ‘System’ properties card (either from control panel, or by typing ‘system’ in search box)

Choose “Advanced System Setting

Card “Advanced” and at the bottom there is “Environment Variables”.

Click “New” under “System variables”. Variable name is JAVA_HOME, variable value is a path to JDK root dir (without quotes) C:\Program Files\Java\jdk1.8.0_65

Maven

Maven is versatile tool used in java projects.

We’re gonna download maven as a binary zip archive.

Extract the contens of a downloaded zip file into directory of your choice.
In our case this will be c:\tools\apache-maven-3.3.9

We’ll need to add maven binaries directory into system path.
Open up “Environment Variables” card, as described in previous step.

On the list of “System variables” find “Path” variable, and choose “Edit”

At the beginning of “Variable value” add path to maven bin subdirectory.
In our case: c:\tools\apache-maven-3.3.9\bin
Remember to FOLLOW the directory with a semicolon!

Start command prompt and verify, that mvn is working correctly, by typing:
mvn -v command

Git

It is possible to instal git alone, but under windows it’s suggested to install git along with git extenstions.

All releases are in gitextensions github page, download and run “SetupComplete.msi” version

On one of the pages chose to install both msysgit and kdiff

Installer will start installation of kdiff and git itself.
During git installation, we suggest to tick Windows Explorer Integration:

and on one of the following cards Use Git from the Windows Command Prompt (this makes things easier)

and on last card Checkout as-is, commit as-is, this is especially important
for projects where developers work on different OSes.

nem.core

As a last step in this episode, let’s try to download and compile nem.core, to verify that installation succeeded.

First create some directory, where you will want to keep the source code, in our examples, this will be:
c:\projects\nem

Start command prompt, change directory to created one and clone nem.core repository using command:

cd C:\projects\nem
git clone https://github.com/NewEconomyMovement/nem.core.git

Still Inside the command prompt, switch to nem.core directory, and try to compile nem.core using commands:

cd nem.core
mvn clean compile install

This gonna take a while as it will first download all the dependencies and will also run all the tests.

There are two tests, that might occasionally fail, if that’s happen to you try compiling using command:

mvn clean compile install -DskipTests=true

5 Likes

Awesome! Thanks @gimre for writing this up!

Great! Looking forward to other episodes. This will bring a huge added value!

1 Like

In the hope it may help someone: to install maven, I use http://sdkman.io/ , very easy.

Hi I´m getting this message. Where on my way have i done something wrong? Im quite new to this stuff, thx for answers :smiley:

Hello.

The message says it all.

JDK and JRE are 2 different things.
JDK = Java Development Kit
JRE = Java Runtime Environment

JRE has not compiler included therefore and is used only to run precompiled java programs.
Prior to installing apache maven you need to install the java JDK.

You can check for version by typing in command line:
java -version // this will check your jre version
javac -version // this will check your java compiler version if you installed

I hope this helps.

edit:
correction; I deleted everything and tried it again and it worked, dunno what the problem was.

Thanks for the fast respons.
Ok, I mean that was the first step of the tutorial and i dind´t skip it, but you are correct by testing “javac -version” I found out it isn´t installed. I think I have done something wrong with the “JAVA_HOME” variables.

In the example he is downloading “jdk-8.u65-…” and set the variable to “C:\Program Files\Java\jdk1.8.0_65”, the newer version is “jdk-8.u131” so the correct direction would be “C:\Program Files\Java\jdk1.8.0_131” ?

If this is correct than maybe the information at the beginning of the tutorial is wrong, “We’ll pick x64 Java Developement Kit (JDK). JDK automatically installs Java Runtime Environment (JRE).” ?

I have followed the instructions as above. I am getting this error while compiling with cmd.

[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
org.apache.maven.lifecycle.NoGoalSpecifiedException: No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy.
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:94)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException

seems like you’re in wrong directory

1 Like

The error was because I had Java 7.1 set as JAVA_HOME in my envoirment

The error was because I had Java 7.1 set as JAVA_HOME in my envoirment