Stendhal on Eclipse: Difference between revisions
imported>Hendrik Brummermann |
imported>Hendrik Brummermann added images |
||
| Line 1: | Line 1: | ||
{{Navigation for Stendhal Top|Building & Hosting}} |
{{Navigation for Stendhal Top|Building & Hosting}} |
||
This guide describes how to setup a development environment in Eclipse for Stendhal. |
|||
== Get Eclipse== |
== Get Eclipse== |
||
* Go to |
* Go to https://www.eclipse.org/downloads/ |
||
* Download: "Eclipse IDE for Java Developers" |
* Download: "Eclipse IDE for Java Developers" |
||
* Unzip the download an run Eclipse |
|||
* In Eclipse, close the "Welcome" window |
|||
You can click on the following images to see them in large. |
|||
<gallery> |
|||
File:Eclipse_00.png|On the first run of Eclipse, this "Welcome" window is shown. Please close it. |
|||
File:Eclipse_00a.png|Typical window layout with the Package Explorer on the left hand side and an empty area for editors in the middle |
|||
</gallery> |
|||
== New Project from Git == |
== New Project from Git == |
||
| Line 10: | Line 22: | ||
In Eclipse: |
In Eclipse: |
||
* Open package explorer view. |
|||
* Select "File -> Import -> Git -> Projects from Git" and click "Next". |
|||
* Select "Clone URI" and click "Next". |
|||
* Fill in the following information: |
|||
<pre> |
<pre> |
||
Revision as of 22:42, 21 June 2015
This guide describes how to setup a development environment in Eclipse for Stendhal.
Get Eclipse
- Go to https://www.eclipse.org/downloads/
- Download: "Eclipse IDE for Java Developers"
- Unzip the download an run Eclipse
- In Eclipse, close the "Welcome" window
You can click on the following images to see them in large.
-
On the first run of Eclipse, this "Welcome" window is shown. Please close it.
-
Typical window layout with the Package Explorer on the left hand side and an empty area for editors in the middle
New Project from Git
In Eclipse:
- Open package explorer view.
- Select "File -> Import -> Git -> Projects from Git" and click "Next".
- Select "Clone URI" and click "Next".
- Fill in the following information:
For anonymous checkout: URI: git://git.code.sf.net/p/arianne/stendhal For privileged checkout: URI: ssh://username@git.code.sf.net/p/arianne/stendhal Host: git.code.sf.net Repository path: /p/arianne/stendhal Protocol: "git" (for anonymous) or "ssh" (for privileged). Port: Can be left blank. Username: Only required for privileged checkout. Password: Will be prompted for if left blank on privileged checkout.
Configure Project
- In the New Project wizard select Java -> Java Project (do not select a simple "general" project!) and click "Next".
- Project name: stendhal ( or whatever you like to call it ).
- Under the section named "JRE" make sure a Java version 1.5 or higher is selected and click "Finish".
- Right click on your project folder and select "Properties" in the context menu.
- Then select "Java Build Path" on the left side of the dialog box.
- Now remove all existing folders from source path and add the two source folders 'src' and 'tests' by clicking on the "Add Folder..." button
- On the "Libraries" tab: click on the "Add JARs" button and select all the *.jar-files in stendhal/libs (some versions of eclipse may automatically import the .jar files). NOTE: If project checkout did not complete before the Create New Project Wizard starts you may have to add the .jar files later. To get to the project properties page either select "Project" from the menu bar then select "Properties" or right-click the root folder in the Package Explorer panel then select "Properties" from the drop-down menu. Updated screenshots to be added.
- Check the text encoding at Project -> Properties -> Resource -> Text Encoding. Set it to UTF-8 unless it is that already.
source folder #1:
stendhal/src
Included:(All)
Excluded:(None)
Native library location: (None)
source folder #2:
stendhal/tests
Included:(All)
Excluded:(None)
Native library location: (None)
default output folder: stendhal/bin
NOTE: For newer versions of eclipse an asterix (*) may need to be added manually to "Included". If the project is already checked out just right-click "src" & "tests" in the Package Explorer panel & select Build Path > Configure Inclusion / Exclusion Filters... Under "Inclusion patterns" select "Add" then input "*" and select "OK" then "Finish". Updated screenshots to be added.
Eclipse should be able to compile the source code now. There could be a little yellow sign (signalling warning messages) before your project folder but there must not be red X (error messages). The package explorer should now display the "src" folder below the root folder with a different icon, the icon is like a small grid.
Trouble Shooting
menu Windows | Preferences | Java | Installed JREs
- there should be at least one entry with a valid JAVA_HOME path (make it so so JDK compliance is at least Java 7)
To make it run the server in Debug mode
- In the toolbar there is the "Debug" button, which looks like a little, green bug. There is a little black arrow on the right side of it.
- This will open a menu, please choose "Debug configurations ..." ("Open Debug Dialog..." on older versions)
- Then in the dialog select "Java Application" and click on the "new" icon in the top left corner.
Name: StendhalServer
Main class: games.stendhal.server.StendhalServer
* All other settings ("include system libries", "Stop in main", ... can be left at their default value.
on the [Arguments] tab:
VM arguments: -Xmx128M
on the [Classpath] tab:
click UserEntries
button "Advanced"
(*) add folder | OK
and select the project root folder | OK
- button [Debug]
And then the server should be started.
To make the client run
- Open games.stendhal.client.update.Starter.java in the editor
- Then again the small black arrow on the right side of the green bug. (Or you may also choose to use the "Run" command instead of "Debug" in case you only want to debug the server component.)
- Select "Debug Configurations" (or "Run Configurations...").
- Select Java Application and click the "New" button in upper-left corner.
- On the [Classpath] tab select "User Entries" - button "Advanced" - (*) add folder | OK - and select the project root folder. | OK
yay shiny new client, shiny server
Making patches
If you have modified and tested the code and want to send us a patch, please see How To Create Patch For Stendhal.
Running JUnit Tests in Eclipse
Setting up JUnit tests in Eclipse:
- Click the arrow next to either the green "Run" or "Debug" button.
- Select "Run/Debug Configurations...".
- Select "JUnit" in the left column and press the "New launch configuration" at the top of left column.
- Give it a unique name, like "Stendhal Tests".
- Select "Run all tests in the selected project, package or source folder".
- OPTIONAL: (this step simply reduces the number of directories that Eclipse will search in for tests)
- Press "Search".
- Select "tests" folder under Stendhal root directory and press "OK".
- Under "Test runner" select "JUnit 4".
- Under "Classpath" tab select "User Entries" and press "Advanced" on the right panel.
- NOTE: There should already be a folder under "User Entries" with a "(default classpath)" suffix. Do not delete this folder.
- Select "Add Folders" and press "OK".
- Select the Stendhal root folder and press "OK".
- Now click "Add JARs..." on the right panel.
- Under the Stendhal root folder select all the .jar files in libs and press OK.
- Now press "Apply" to save the configuration or "Run" to save and run it.

