User Tools

Site Tools


installation

Environment and Requirements

The N2S3 simulator is written in the Scala programming language and built using the Scala Build Tool(sbt). We do not provide different versions or installations per different platforms (e.g., unix, windows). Platform differences are managed automatically by N2S3's dependencies.

If this is your first N2S3 installation, you may need to set up you Scala environment. All this boils down to installing Java (which you probably have already installed) and then installing sbt. Sbt will manage the installation of the correct scala version for N2S3 and all its dependencies. Additionally, N2S3's code is stored in a git repository. You need to install git in your machine to be able to load the latest version, or to be able to contribute. Otherwise, you'll need to download a released version.

Follow the up-to-date installation instructions of Java and sbt in your own platform.

N2S3 and/or IntelliJ might not work if you're using OpenJDK11, you should use OpenJDK8 instead.

Make sure you have a good internet connection. Besides the manual installation of these packages. Some of them will also load new packages and dependencies dynamically. At the end, you should be able to test your installation by issuing the following commands in a terminal:

$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
 
$ sbt version
[info] Loading global plugins from /home/guille/.sbt/0.13/plugins
[info] Set current project to nessy (in build file:/home/guille/projects/N2S3/nessy/)
[info] 0.1-SNAPSHOT

There are two main ways to install N2S2: as a library (for example, using a packaged jar) or by building it from sources.

Recommended: Declare N2S3 as an SBT dependency

This is the recommended way to install N2S3. Using this method, you'll not have to manage dependencies, download or even versionning of N2S3 packages.

To import N2S3 in your project, you just need to add the following two dependencies to your project. SBT will make sure to get all the rest of them. Just add the following couple of dependencies on your SBT file as follows:

name := "My Project"
version := "1.0"
scalaVersion := "2.11.6"
 
libraryDependencies ++= Seq(
  "fr.univ-lille.cristal" %% "n2s3" % "1.1.1" exclude("net.sf", "jaer_2.11"),
  "net.sf" %% "jaer" % "1.0" from "https://sourcesup.renater.fr/frs/download.php/file/5047/jaer.jar"
)

You'll notice that we need also to add the dependency to JAER explicitly. This happens because JAER is not published in a public repository as Sonatype. Instead, we host a version of JAER that needs to be explicitly marked as dependency.

An example of such sbt project can be found in: https://github.com/guillep/n2s3_examples/tree/master/n2s3_sbt_dependency

Creating a SBT project

Sbt is a tool that helps to manage the life-cycle of a scala project. It helps automatizing several of the common tasks we do in the day-to-day such as compiling, testing, packaging, deploying, and it provides us with tools to customize our project's life-cycle. In this tutorial we briefly explain how to create a sbt project to get started with N2S3. If you want to get deeper knowledge on it, we suggest you to read the getting started docs of sbt.

Sbt works by convention. That it, it expects that sources files are in particular places to work correctly. More concretely, it expects a structure like this:

  • src
    • main
      • java: the main source code written in java
      • scala: the main source code written in scala
    • test
      • java: the project tests written in java
      • scala: the project tests written in scala

It also expects that in the root of the project there is a build.sbt file that contains the project properties, such as the project name, version, dependencies, etc… The following bash script, adapted from the one found in the scala cookbook, would create the correct directory structure for you:

# create the directory structure
mkdir -p src/{main,test}/{java,resources,scala}
mkdir lib project target
 
# create an initial build.sbt file
cat > build.sbt << END
lazy val n2s3 = (project in file(".")).settings(
  name             := "MyProject",
  version          := "0.1",
  organization     := "my.organization",
  scalaVersion     := "2.11.6",
  scalacOptions    := Seq("-unchecked", "-deprecation", "-encoding", "utf8")
)
END

Notice that you can already customize your build.sbt file to put the correct project name, organization name, and version number. We recommend to use by default the other options in the script (compilation, scala version) unless you know what you're doing.

Also, if you're going to save your code in git, we also recommend you setting up a .gitignore file that is aware of the project's sbt-ness. The following bash script will create a correct gitignore file for you:

cat > .gitignore << END
#SBT specific
.cache/
.history/
.lib/
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
END

Alternative 1: Loading N2S3's Assembly (fat-jar)

With sbt we can define a dependency indicating the url to a jar file. At build time, sbt will load the specified jar before it compiles. This approach only loads the specified jar without any meta-data. Then, this approach does not load any of the jar dependencies. We recommend to only use this approach with N2S3's assembly, as it follows in the following piece of code, but a user willing to use this approach could (at his own risk) import the jar and describe all of the jar dependencies by himself in his own sbt project.

lazy val n2s3_examples = (project in file(".")).settings(
  scalaVersion     := "2.11.6",
  scalacOptions    := Seq("-unchecked", "-deprecation", "-encoding", "utf8"),
 
  /*********************************************************************************************************************
    * Dependencies
    *******************************************************************************************************************/
  libraryDependencies += "fr.cristal.emeraude" %% "n2s3" % "1.1.1-ASSEMBLY-SNAPSHOT" from "https://sourcesup.renater.fr/frs/download.php/file/5304/N2S3-assembly-1.1.1.jar"
)

Alternative 2: Installing N2S3 as an unmanaged library

A third approach to install N2S3 is to handle it as an unmanaged library. By installing a jar inside the /lib directory of our project, sbt will be able to see and import our dependencies and use them to compile and build our project. Again, this approach does not manage a library's dependencies. So we recommend you install the corresponding assembly version into your lib directory, or you install the normal jar along with all its dependencies.

Manual Download: Jar files

We release two different N2S3 distributions. They are essentially the same N2S3 version, but they provide different facilities depending on the user:

  • Jar. A normal Jar distributing only N2S3's compiled code. This version does not contain N2S3 dependencies and thus a separate process is required to load them. This version is mostly for users used to scala and java and have used maven or sbt at least once. This version is the recommended if you want to embed N2S3 within a bigger application with more dependencies.
  • Assembly. A fat-jar distributing both N2S3's code and all dependencies. This version is the recommended for casual N2S3 users that are only using N2S3.

Besides these different versions, we recommend you to manage your scala project with sbt. In the following two subsections we present two different ways to import a N2S3 dependency in your SBT project.

N2S3 Jar

N2S3 Jar is a packaged jar containing N2S3.

Download Jar V1.1.1: Download

Download Jar V1.1: Download

Download Jar V1.0: Download

Create an sbt project and add the jar as an unmanaged library. Then, since this jar does not contain dependencies, you should express them in your sbt file, as follows:

name := "My Project"
version := "1.0"
scalaVersion := "2.11.6"
 
unmanagedJars in Compile += file("../lib/n2s3_2.11-1.1.1.jar")
 
libraryDependencies ++= {
  val scalaXmlV = "1.0.2"
  val akkaV = "2.3.7"
  val scalatestV = "2.2.1"
  Seq(
    "org.scala-lang.modules" %% "scala-xml" % scalaXmlV,
    "com.typesafe.akka" %% "akka-actor"      % akkaV,
    "com.typesafe.akka" %% "akka-testkit"    % akkaV,
    "com.typesafe.akka" %% "akka-cluster"    % akkaV,
    "org.scalatest"     %% "scalatest"       % scalatestV % "test",
    "com.squants"  %% "squants"  % "0.5.3",
    "com.storm-enroute" %% "scalameter" % "0.7",
    "com.xeiam.xchart" % "xchart" % "2.5.0" exclude("de.erichseifert.vectorgraphics2d", "VectorGraphics2D"),
    "net.sf" %% "jaer" % "1.0" from "https://sourcesup.renater.fr/frs/download.php/file/5047/jaer.jar"
  )
}

An example of such sbt project can be found in: https://github.com/guillep/n2s3_examples/tree/master/n2s3_sbt_jar

Note that alternatively, you can add the jar using your preferred IDE.

N2S3 Assembly Jar

N2S3 Assembly Jar is a packaged jar containing N2S3 and all its dependencies.

Download Assembly Jar V1.1.1: Download

Download Assembly Jar V1.1: Download

Download Assembly Jar V1.0: Download

Create an sbt project, add the Jar to your project as an unmanaged library (or using your IDE's options, if you prefer). This jar includes all dependencies for N2S3, so you do not need to express dependencies in the sbt file. Your sbt file can look just like:

name := "My Project"
version := "1.0"
scalaVersion := "2.11.6"
 
unmanagedJars in Compile += file("../lib/n2s3-assembly-1.1.1.jar")

Be careful, this may look like the easiest way to use N2S3, but this may introduce some version conflicts if you are using also external libraries.

An example of such sbt project can be found in: https://github.com/guillep/n2s3_examples/tree/master/n2s3_sbt_assembly

Virtual machine

You can download a virtual machine that contains everything you need to use N2S3. Be aware that this virtual machine is quite heavy (6Go) and takes a lot of resources, so this option is mainly useful if you just want to modify N2S3 and don't need a lot of resources.

https://nextcloud.univ-lille.fr/index.php/s/SLrap97mnHdnDdk

IntelliJ is installed on this VM so you will be able to use and modify N2S3 easily.

You can import this VM using VirtualBox or any other virtualization tool.

username : n2s3
password : n2s3

Older Versions

To check for older (or even development SNAPSHOT releases), check the following link: https://sourcesup.renater.fr/frs/?group_id=2343.

installation.txt · Last modified: 2019/07/31 13:29 by sylvain.clay.etu@univ-lille.fr