Tutorial: Building Cloudsim and running an example

Today I read this paper presenting Cloudsim. Since truth lies in the code I wanted to download the Cloudsim source code, build it and run the examples. Things turned south and I and a friend had to google our way through some guides, and then solve additional errors not mentioned in those guides (maybe an issue caused by a newer release of Cloudsim).

Step 0 – Requirements

The requirements are nothing out of the ordinary, the main software required is:

  1. Winrar (or anything that will allow you to extract zip files)
  2. Java IDE – such as Netbeans, eclipse etc’- I’ll be using Netbeans
  3. Java & JDK

I won’t list specific versions – the latest versions of this tools should do and I don’t suspect that there anything would break.

Step 1 – Downloading the code

Cloudsim code can be found on Github here. I expected this would be the code I would download and compile, but no – there is a release version built for us (don’t be so happy yet, the built version is missing stuff , as I’ll explain). This tutorial is written on version 4.0 but I expect it to work on future versions as well.

step 1 is to go to the release page, linked above, enter a specific version, such as cloudsim 4.0, and download both zip files available, in this case cloudsim-4.0.zip and the Source code (zip).

Step 2 – Creating a project in the IDE and copying files

  1. Extract both the above zip files
  2. Create a standard java console project
  3. From the release folder (not the source code folder) at cloudsim-4.0\cloudsim-4.0\jars copy both jar files (cloudsim-4.0.jar and cloudsim-examples-4.0.jar) to your project folder. In Netbeans this results in copying the files to the project folder (in the same place where your nbproject sits).
  4. From: cloudsim-cloudsim-4.0\cloudsim-cloudsim-4.0\modules\cloudsim\src\main\java copy the folder named “org” to your source folder (in netbeans structure we go to a folder called “src” and copy the above into the src folder).
  5. From: cloudsim-cloudsim-4.0\cloudsim-cloudsim-4.0\modules\cloudsim-examples\src\main\java\org\cloudbus\cloudsim copy the “examples” folder into the following path: {the path of the copied org folder}\cloudbus\cloudsim (this folder have many folders and files, we want to add the examples folder to that folder).
  6. In your IDE – add the two JAR files we copied in step 3. 

Step 3 – Fixing Apache Commons Math

After Step 2 we have a broken build, this is caused by two reasons and not having Apache Commons Math is one of them.

What you want to do is download a jar file for this library and add it from the IDE as well. The repository for Apache Commons Math can be found here  and I downloaded the latest version at the time which is 3.6.1.

Step 4 – Fixing OpenCsv errors


Another missing library is OPenCsv, can be found here . Download the jar file and add it to your project (I downloaded version 2.3 which was the latest at the time of writing this).

Step 5 – Building & Running examples

Your project should now build without errors! To run the examples go to your source packages, to a package named “org.cloudbus.cloudsim.examples” and to one of the example files you want to run (for example CloudSimExample1.Java). This file has a main method which you can run (in netbeans – right click->debug file + adding a breakpoint at the beginning of the main method).

You should now be up and running! to see the description of the examples see this site.

That’s it! Hope it helped,





Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: