Stendhal on Eclipse: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>Kymara out of date notice |
imported>Hendrik Brummermann |
||
| (464 intermediate revisions by 18 users not shown) | |||
| Line 1: | Line 1: | ||
{{Navigation for Stendhal Top|Building & Hosting}} |
|||
<pre>'''This could be out of date since it was written pre- stendhal 0.63 and marauroa 2.0. Please help keep up to date if you find errors.''' </pre> |
|||
==First Steps== |
|||
This guide describes how to setup a development environment in Eclipse for Stendhal. |
|||
# First of all open the view called Package Explorer. |
|||
# Create new 'Java Project' |
|||
== Get Java == |
|||
# make sure that the marauroa.ini is in your stendhal project folder. |
|||
* If you can play Stendhal, you already have Java and can skip this step. |
|||
# right click on your project folder and select "Properties" in the context menu. |
|||
* If you do not have java installed, please download it https://java.com<br> (if you are on Linux, use your packet manager) |
|||
# then select "Java Build Path" on the left side of the dialog box. |
|||
<pre>source folder: stendhal/src |
|||
== Get Node.js == |
|||
default output folder: stendhal/classes |
|||
On the "library" tab: [Add jars] and select all the files in stendhal/lib</pre> |
|||
* https://nodejs.org (optional: for building & using web client) |
|||
Eclipse should be able to compile the source code now. There should be a little yellow sign before your project folder but not red X. The package explorer should now display the "src" folder directly below the root folder with a different icon, the icon is like a small grid. |
|||
== Get Eclipse== |
|||
* Go to https://www.eclipse.org/downloads/ |
|||
* Download: "Eclipse IDE for Java Developers" |
|||
* Unzip the download and 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> |
|||
Note: If you installed Eclipse in Ubuntu via a package manager, also install: "eclipse-egit" |
|||
== New Project from Git == |
|||
In Eclipse: |
|||
* Open menu "File -> Import |
|||
* In the dialog select: "Git -> Projects from Git" and click "Next". |
|||
* Select "Clone URI" and click "Next". |
|||
* 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" |
|||
* On the Branch selection page, keep everything selected and click "Next" |
|||
* Under "Destination" choose the directory where you want to download the source code and select "Next". |
|||
* Eclipse will now download Stendhal from git, this may take a while |
|||
* "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: |
|||
<gallery> |
|||
Eclipse 01.png|Open File | Import |
|||
Eclipse 02.png|Import from Git |
|||
Eclipse 03.png|Clone URI |
|||
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 06.png|Just click "next" on destination |
|||
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> |
|||
==Trouble Shooting== |
==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 5.0 ?) |
|||
After completing the import wizard, Eclipse should look like the following screenshot: |
|||
If you happen to get this: |
|||
'' The method getLayerVector() is undefined for the type MapMapConverter.javastendhal/src/games/stendhal/toolsline 111'' |
|||
[[File:Eclipse 10.png]] |
|||
* please right click your project folder again --> properties -> java build path. |
|||
* in the [source] tab there should only be stendhal/src, so remove stendhal/tiled/src |
|||
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. |
|||
(This entry has higher priority than the tiled.jar in the libs folder but this code is highly outdated) |
|||
==To make it run the server== |
|||
== Start StendhalServer == |
|||
* In the toolbar there is a green icon which looks like a 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. |
|||
* This will open a menu, please choose "Debug..." |
|||
[[File:Eclipse_debug_configurations_menu.png]] |
|||
* Then in the dialog select "Java Application" and click on the "new" icon in the top left corner. |
|||
* This will open a menu, please choose "Debug configurations ..." ("Open Debug Dialog..." on older versions) |
|||
<pre> Name: StendhalServer |
|||
* Then in the dialog select "Java Application" and click on the "new" icon in the top left corner. |
|||
Main class: marauroa.server.marauroad |
|||
[[File:Eclipse_new_debug_configuration.png]] |
|||
[x] include libaries when searching for the main class |
|||
on the [Arguments] tab: |
|||
Name: StendhalServer |
|||
Program arguments: -c marauroa.ini -l |
|||
Main class: games.stendhal.server.StendhalServer |
|||
on the [Classpath] tab: |
|||
button "Advanced" |
|||
* All other settings ("include system libries", "Stop in main", ... can be left at their default value. |
|||
(*) add folder | OK |
|||
* on the [Arguments] tab: VM arguments: -Xmx128M |
|||
and select the root folder </pre> |
|||
* on the [Classpath] tab: click "UserEntries" - button "Advanced" - (*) add folder | OK - and select the "stendhal" project root folder | OK |
|||
* button [Debug] |
* button [Debug] |
||
And then the server should be started. |
And then the server should be started. |
||
'''Note: you may need to 'add external jars' and add your mysql jar from your ant build type server, if you have that already, or download from http://dev.mysql.com/downloads/connector/j/3.0.html''' (there are newer mysql available on the same site but I have 3.0 and it seems fine.) |
|||
NOTE: On newer Eclipse versions, the [Classpath Entries] are under Dependencies tab. |
|||
==To make the client run== |
|||
# Open games.stendhal.client.update.Starter.java in the editor |
|||
== Start Stendhal Client == |
|||
# then again the small black arror on the right side ofthe green bug. |
|||
# Open games.stendhal.client.update.Starter.java in the editor |
|||
# java application -> new-icon, and it should be prefilled. |
|||
# Then again the small black arrow on the right side of the green bug. |
|||
# for the client the [Classpath] advanced root folder thingy is needed as well. |
|||
# 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 |
|||
== 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== |
|||
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: |
|||
# 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. |
|||
yay shiny new client, shiny server |
|||
[[Category:Stendhal]] |
[[Category:Stendhal]] |
||