Stendhal on Eclipse: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>Hendrik Brummermann |
imported>Hendrik Brummermann |
||
| (31 intermediate revisions by 5 users not shown) | |||
| Line 3: | Line 3: | ||
This guide describes how to setup a development environment in Eclipse for Stendhal. |
This guide describes how to setup a development environment in Eclipse for Stendhal. |
||
== Get Java == |
|||
* If you can play Stendhal, you already have Java and can skip this step. |
|||
* If you do not have java installed, please download it https://java.com<br> (if you are on Linux, use your packet manager) |
|||
== Get Node.js == |
|||
* https://nodejs.org (optional: for building & using web client) |
|||
== Get Eclipse== |
== Get Eclipse== |
||
| Line 8: | Line 16: | ||
* Go to https://www.eclipse.org/downloads/ |
* Go to https://www.eclipse.org/downloads/ |
||
* Download: "Eclipse IDE for Java Developers" |
* Download: "Eclipse IDE for Java Developers" |
||
* Unzip the download |
* Unzip the download and run Eclipse |
||
* In Eclipse, close the "Welcome" window |
* In Eclipse, close the "Welcome" window |
||
| Line 17: | Line 25: | ||
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 |
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> |
</gallery> |
||
Note: If you installed Eclipse in Ubuntu via a package manager, also install: "eclipse-egit" |
|||
== New Project from Git == |
== New Project from Git == |
||
| Line 25: | Line 34: | ||
* In the dialog select: "Git -> Projects from Git" and click "Next". |
* In the dialog select: "Git -> Projects from Git" and click "Next". |
||
* Select "Clone URI" and click "Next". |
* Select "Clone URI" and click "Next". |
||
* Fill in the following information: |
* Fill in the following information: |
||
** '''URI''': |
|||
*** GitHub readonly: <code><nowiki>https://github.com/arianne/stendhal.git</nowiki></code><br>(if you have a github account, please go to https://github.com/arianne/stendhal and click on "Fork" to create you own copy of the repository and then use that in Eclipse instead) |
|||
*** GitHub read/write (SSH): <code><nowiki>git@github.com:arianne/stendhal.git</nowiki></code> |
|||
* The result of the fields are filled in automatically, click "Next" |
* The result of the fields are filled in automatically, click "Next" |
||
* On the Branch selection page, keep everything selected and click "Next" |
* On the Branch selection page, keep everything selected and click "Next" |
||
| Line 31: | Line 43: | ||
* Eclipse will now download Stendhal from git, this may take a while |
* Eclipse will now download Stendhal from git, this may take a while |
||
* "Import existing projects" and select "Next" |
* "Import existing projects" and select "Next" |
||
* "Finish" import of project Stendhal |
|||
Click on the screenshots to enlarge them, if you need help with any of the steps: |
Click on the screenshots to enlarge them, if you need help with any of the steps: |
||
| Line 40: | Line 53: | ||
Eclipse 04.png|Fill in URI and watch the remaining fields to be filled automatically |
Eclipse 04.png|Fill in URI and watch the remaining fields to be filled automatically |
||
Eclipse 05.png|Just click "next" on branch selection |
Eclipse 05.png|Just click "next" on branch selection |
||
Eclipse 06.png|Just click "next" on |
Eclipse 06.png|Just click "next" on destination |
||
Eclipse 07.png|Wait for the download to complete. This may take quite a while |
Eclipse 07.png|Wait for the download to complete. This may take quite a while |
||
Eclipse 08.png|Import existing project |
|||
Eclipse 09.png|Confirm import of project "Stendhal" by clicking finish |
|||
</gallery> |
</gallery> |
||
| ⚫ | |||
== Configure Project == |
|||
After completing the import wizard, Eclipse should look like the following screenshot: |
|||
* Check the text encoding at Project -> Properties -> Resource -> Text Encoding. Set it to UTF-8 unless it is that already. |
|||
[[File:Eclipse 10.png]] |
|||
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" and "test" folder below the root folder with a different icon, the icon is like a small grid. |
|||
There is a project called "stendhal" listed in the Package Explorer view. There may be a tiny yellow triangle in front of the blue project icon. But if you see a red circle or a red exclamation mark, something went wrong. In this case there will be an error in the "Problems" view at the bottom. |
|||
| ⚫ | |||
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) |
|||
== Start StendhalServer == |
|||
==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. |
* 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. |
||
[[File:Eclipse_debug_configurations_menu.png]] |
[[File:Eclipse_debug_configurations_menu.png]] |
||
| Line 61: | Line 76: | ||
[[File:Eclipse_new_debug_configuration.png]] |
[[File:Eclipse_new_debug_configuration.png]] |
||
Name: StendhalServer |
|||
Main class: games.stendhal.server.StendhalServer |
Main class: games.stendhal.server.StendhalServer |
||
* All other settings ("include system libries", "Stop in main", ... can be left at their default value. |
* All other settings ("include system libries", "Stop in main", ... can be left at their default value. |
||
| ⚫ | |||
* on the [Classpath] tab: click "UserEntries" - button "Advanced" - (*) add folder | OK - and select the "stendhal" project root folder | OK |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
VM arguments: -Xmx128M |
|||
NOTE: On newer Eclipse versions, the [Classpath Entries] are under Dependencies tab. |
|||
click UserEntries |
|||
button "Advanced" |
|||
(*) add folder | OK |
|||
and select the project root folder | OK |
|||
</pre> |
|||
| ⚫ | |||
| ⚫ | |||
== |
== Start Stendhal Client == |
||
# Open games.stendhal.client.update.Starter.java in the editor |
# Open games.stendhal.client.update.Starter.java in the editor |
||
# Then again the small black arrow on the right side of the green bug. |
# Then again the small black arrow on the right side of the green bug. |
||
# Select "Debug Configurations" (or "Run Configurations..."). |
# Select "Debug Configurations" (or "Run Configurations..."). |
||
# Select Java Application and click the "New" button in upper-left corner. |
# 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 |
# 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 == |
== Making patches == |
||
| Line 93: | Line 100: | ||
==Running JUnit Tests in Eclipse== |
==Running JUnit Tests in Eclipse== |
||
This is an advanced topic. If you make changes to the Java code, it is a good idea to run the automatic test. |
|||
Setting up JUnit tests in Eclipse: |
Setting up JUnit tests in Eclipse: |
||
# Click the arrow next to either the green "Run" or "Debug" button. |
# Click the arrow next to either the green "Run" or "Debug" button. |
||