Setup Eclipse for use with SIMON¶
This is how to setup your Eclipse IDE to work with SIMON. But remember: This is only ONE possible solution. There might be others, more complex or more easy...
Download latest SIMON release¶
See Get SIMON for downloading the latest release of SIMON. For this tutorial, you should use the "simon-X.X.X-__jar-with-dependencies__.jar" JAR archive...
First of all, you need to start Eclipse. Usually you're asked to specify a workspace directory
After clicking OK, the IDE should somehow look like this:
Add SIMON as a User Library¶
Before you can start to code, you should setup SIMON as a library in Eclipse. This is done by adding a "User Library". For doing this, click on "Window" in the menu bar and choose "Preferences" in the menu. A dialog will open. Navigate to the entry as shown in the next screenshot:
Click on "New" ...
and enter "SIMON" as the name of the library. After this, you return to the preferences dialog. Select the new "SIMON" entry and click on "Add JARs". Now you have to specify the downloaded SIMON release. For easy use, choose the jar archive named like "simon-X.X.X-__jar-with-dependencies__.jar". Now the preference dialog should look like this:
Okay, you've setup the user library for SIMON. Now it's time to create your project.
As SIMON is used for client/server applications, there are normally three parts involved:
- The client code
- The server code
- The shared code, which is used by client AND server
So we need to create three projects. Click on "File" in the menu bar and choose "New" -> "Java Project". A dialog like this will open:
This has to repeated three times. In our example we create the following projects:
- SIMON Client
- SIMON Server
- SIMON Shared
Now you should have a workspace like this:
Prepare projects for use with SIMON¶
Before we can make use of the SIMON library in our projects, we first have to add SIMON to each project's classpath. For doing this, right click on the project's name in the package view and select "Properties". Navigate to the view as shown by the next screenshot:
Click on "Add Library" ...
... choose "User Library" ...
... and finally select SIMON and click "Finish".
Your "Package Explorer View" will now look like this:
As you now have created the projects, you can add some code. In our example here, we will use the "Hello World" sample described here.
Simply copy & paste the source to the respective project:
- The two interfaces "ServerInterface" and "ClientCallbackInterface" go into "SIMON Shared"
- "ServerInterfaceImpl" as well as "Server" goes into "SIMON Server"
- "ClientCallbackImpl" as well as "Client" goes into "SIMON Client"
While copy&pasting, you will experience some errors:
That's quite normal at this stage. Rigth now, we did not setup the dependency between "SIMON Server" and "SIMON Shared", and "SIMON Client" and "SIMON Shared". For both, the "client" and "server" project, right-click on the project name and select "Properties". Navigate to the view as shown by the next screenshot:
You see that in the screenshot the dependency to the "shared" project is already defined. So you have to click on "Add..." and select your shared project. That's all.
After doing this, you projects will compile without any error.
Run Your Application¶
Now it's time to run your application. In our example, rigth-click on the "Server"-class in the Package Explorer and choose "Run as" -> "Java Application". You console will now show:
Server up and running!
And for starting the client, do the same with the "Client"-class. Your client console will show output like this:
This message was received from the server: This is the callback. Your address is /127.0.0.1 and your are connected from port 4930