jSpace Setup Guide

Table of Contents:

Contact Benjamin Bogø if you found a problem or have suggestions for improvements/additions.

1 [Eclipse] Create Maven Project

1.1 Open Create Project

In the top, select File and in the dropdown select New > Project...

1.2 Select Maven

In the dialog, select the item Maven Project under the folder named Maven. Afterwards, click on .

1.3 Simple Project

In the next dialog, make sure to check Create a simple project (skip archetype selection). Then click on .

1.4 Artifact Settings

The next page in the dialog is confusing for people that uses Maven for the first time. Here is what you have to fill in as a minimum:

  • Group Id corresponds to the company name part of the package name (in lowercase) of your project i.e. Google would use com.google. You could use dk.dtu or something else.
  • Artifact Id is the project name part of the package name (in lowercase) of your project i.e. Google gson would use gson here (as com.google is part of the Group Id). You could use project_02148 or something else.
Input: Maven Group Id.
Input: Maven Artifact Id.

You do not have to fill in more. Click on to create the project.

1.5 Check JRE version

Open the newly created project (click the arrow). Find the item named JRE System Library... and check that it is the correct version. I needs to be Java 11+. If not, right-click on JRE System Library... and in the dropdown select Properties. Then select the wanted JRE and click .

2 [Eclipse] Add jSpace Dependency

2.1 Open Dependency Management

Open the newly created project (click the arrow), and open the file pom.xml. When the file is opened, there are some tabs in the bottom of the window. Click on the tab called Dependencies.

2.2 Add jSpace Dependency

In the Dependencies tab, click on . In the new dialog, fill out the following:

  1. Group Id should be io.github.pspaces.jspace.
  2. Artifact Id should be common.
  3. Version should be [0.0,).

Finish by clicking on .

2.3 Saving Dependencies

After having added the jSpace dependency, then remember to save the file for the changes to take effect!

3 [Eclipse] Check that jSpace Works

3.1 Create Project

It is assumed that you followed Part 1 and Part 2 such that you have a Maven Eclipse project we can play with.

3.2 Create TestJSpace Class

Right-click on the project. In the dropdown, choose New > Class.

An options dialog will now be shown. Set the Name of the class to TestJSpace (important!). At the top, make sure that the Package name is <groupId>. Click on the button.

Copy the code below and paste it into the newly created TestJSpace.java file (the old contents of the file should be deleted). Save the file.

package <groupId>;

import org.jspace.FormalField;
import org.jspace.SequentialSpace;
import org.jspace.Space;

public class TestJSpace {

    public static void main(String[] argv) throws InterruptedException {
        Space inbox = new SequentialSpace();
        inbox.put("Hello World!");
        Object[] tuple = inbox.get(new FormalField(String.class));
        System.out.println(tuple[0]);
    }

}

3.3 Run Program

Click on the (green) run button. If it works, you should see that Hello World! is printed to the console AND jSpace works (you are done here). If it does not work, continue to the next step.

3.4 (OPTIONAL) Create Run Configuration

In the top menu bar, choose Run > Run Configurations.... Above the type filer text input on the left side, there are some small icons. Click on the first (on hover, it should say New launch configuration). On the Main tab, select the correct Project and Main class (use the and buttons). Change to the JRE tab and make sure that the first option Project JRE (...) is selected. Click on and then click on the button. If it still does not work, please contact Benjamin.

4 [IntelliJ] Create Maven Project

4.1 Open Create Project Dialog

If you have no prior projects, then click on in the upper right corner. Otherwise, select File in the top and in the dropdown choose New > Project....

4.2 Create Maven Project

In the dialog on the left, select Maven Archetype under Generators. Then, give the project a Name and choose a Java version that is 11+.

Next, choose the Archetype called maven-archetype-quickstart and the highest Version under it.

Finally, expand the Advanced Settings in the bottom and fill out the following two fields:

  • Group Id corresponds to the company name part of the package name (in lowercase) of your project i.e. Google would use com.google. You could use dk.dtu or something else.
  • Artifact Id is the project name part of the package name (in lowercase) of your project i.e. Google gson would use gson here (as com.google is part of the Group Id). You could use project_02148 or something else.
Input: Maven Group Id.
Input: Maven Artifact Id.

5 [IntelliJ] Add jSpace Dependency

5.1 Open pom.xml

Expand the newly created project in the left sidebar and then open the file pom.xml.

5.2 Add jSpace Dependency

In the pom.xml file, find the <dependencies> tag. It should contain something like:

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

Extend it with:

    <dependency>
      <groupId>io.github.pspaces.jspace</groupId>
      <artifactId>common</artifactId>
      <version>[0.0,)</version>
    </dependency>

Such that it becomes:

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.github.pspaces.jspace</groupId>
      <artifactId>common</artifactId>
      <version>[0.0,)</version>
    </dependency>
  </dependencies>

If the <dependencies> tag is missing, then add the following (somewhere between the <project> and </project> tags):

  <dependencies>
    <dependency>
      <groupId>io.github.pspaces.jspace</groupId>
      <artifactId>common</artifactId>
      <version>[0.0,)</version>
    </dependency>
  </dependencies>

5.3 Fix Bad Maven Version

IntelliJ have a nasty default setting that makes Maven compile with the VERY deprecated Java 5 (1.5). To fix this, do the following: Again in the pom.xml file under <properties>, change everything between <properties> and </properties> to:

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>19</maven.compiler.source>
    <maven.compiler.target>19</maven.compiler.target>
  </properties>

Remember to change the version to the one you use - it should be Java 11+.

5.4 Save Changes

Save the file. Afterwards, there should be a small Maven refresh icon in the top right corner of the file editor. Click on it or nothing will work.

6 [IntelliJ] Check that jSpace Works

6.1 Create Project

It is assumed that you followed Part 4 and Part 5 such that you have a Maven IntelliJ project we can play with.

6.2 Create TestJSpace Class

Open the src/main/java folder all the way down, including the folders corresponding to the Group Id. Right-click the bottom folder and in the dropdown choose New > Java Class. Name the class TestJSpace (important!).

Copy the code below and paste it into the newly created TestJSpace.java file (the old contents of the file should be deleted). Save the file.

package <groupId>;

import org.jspace.FormalField;
import org.jspace.SequentialSpace;
import org.jspace.Space;

public class TestJSpace {

    public static void main(String[] argv) throws InterruptedException {
        Space inbox = new SequentialSpace();
        inbox.put("Hello World!");
        Object[] tuple = inbox.get(new FormalField(String.class));
        System.out.println(tuple[0]);
    }

}

6.3 Run Program

Next to the line numbers in the file TestJSpace.java (when opened), click on one of the green arrows and in the dropdown choose Run 'TestJSpace.main()'. If it works, you should see that Hello World! is printed to the console AND jSpace works (you are done here). If it does not work, then right-click the project under the JAVA PROJECTS in the left sidebar and select Rebuild Project in the dropdown.

7 [VSCode] Create Maven Project

It is assumed that you have installed Visual Studio Code (VSCode) and have installed the following extensions:

7.1 Create Maven Project

Open the command palette (Windows/Linux: + + , MacOS: + + ) and find the option Java: Create Java Project....

Afterwards, it asks which project type that you should create. You should choose Maven.

7.2 Select Archetype

Next, it asks for an archetype. For simplicity, choose maven-archetype-quickstart. Afterwards, choose the highest version available.

7.3 Group and Artifact Ids

Now, it asks for a Group Id which corresponds to the company name part of the package name (in lowercase) of your project i.e. Google would use com.google. You could use dk.dtu or something else.

Next, it asks for an Artifact Id which is the project name part of the package name (in lowercase) of your project i.e. Google gson would use gson here (as com.google is part of the Group Id). You could use project_02148 or something else.

Input: Maven Group Id.
Input: Maven Artifact Id.

7.4 Create Project

Then, it asks for a folder where the project should be placed (create and then select the folder). It will then download some stuff the first time. When it stops downloading, it should ask for something like Define value for property 'version' 1.0-SNAPSHOT. Just press to choose the value it suggested. Afterwards, it asks for confirmation (press again).

Finally, the project is created. It should show a box in the lower right corner. Click on Open to open the project.

8 [VSCode] Add jSpace Dependency

8.1 Open pom.xml

Open the newly created project and then open the file pom.xml in the left sidebar.

8.2 Add jSpace Dependency

In the pom.xml file, find the <dependencies> tag. It should contain something like:

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

Extend it with:

    <dependency>
      <groupId>io.github.pspaces.jspace</groupId>
      <artifactId>common</artifactId>
      <version>[0.0,)</version>
    </dependency>

Such that it becomes:

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.github.pspaces.jspace</groupId>
      <artifactId>common</artifactId>
      <version>[0.0,)</version>
    </dependency>
  </dependencies>

If the <dependencies> tag is missing, then add the following (somewhere between the <project> and </project> tags):

  <dependencies>
    <dependency>
      <groupId>io.github.pspaces.jspace</groupId>
      <artifactId>common</artifactId>
      <version>[0.0,)</version>
    </dependency>
  </dependencies>

8.3 Change Maven Properties

Again in the pom.xml file under <properties>, change the version in <maven.compiler.source> and <maven.compiler.target> to the Java version (11+) you are using.

Eventually, create a folder called .vscode (top-level) with the file .settings with the content (replace the path):

{
    "java.configuration.runtimes": [
        {
            "name": "JavaSE-19",
            "path": "/path/to/jdk/",
            "default": true
        }
    ]
}

8.4 Save pom.xml

After having added the jSpace dependency, then remember to save the file for the changes to take effect!

9 [VSCode] Check that jSpace Works

9.1 Create Project

It is assumed that you followed Part 7 and Part 8 such that you have a Maven VSCode project we can play with.

9.2 Create TestJSpace Class

Open the src/main/java folder all the way down, including the folders corresponding to the Group Id. Right-click the bottom folder and in the dropdown choose New File. Name the file TestJSpace.java (important!).

Copy the code below and paste it into the newly created TestJSpace.java file (the old contents of the file should be deleted). Save the file.

package <groupId>;

import org.jspace.FormalField;
import org.jspace.SequentialSpace;
import org.jspace.Space;

public class TestJSpace {

    public static void main(String[] argv) throws InterruptedException {
        Space inbox = new SequentialSpace();
        inbox.put("Hello World!");
        Object[] tuple = inbox.get(new FormalField(String.class));
        System.out.println(tuple[0]);
    }

}

9.3 Run Program

Right-click on the file TestJSpace.java (or in the code for the file). In the dropdown, choose Run Java near the bottom. If it works, you should see that Hello World! is printed to the console AND jSpace works (you are done here). If it does not work, then right-click the project under the JAVA PROJECTS in the left sidebar and select Rebuild Project in the dropdown.