Stendhal on Eclipse: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>Kymara
initial IRC chat!!
imported>Hendrik Brummermann
 
(492 intermediate revisions by 18 users not shown)
Line 1: Line 1:
{{Navigation for Stendhal Top|Building & Hosting}}
<kymara> so do you have any idea how i'd run teh server from eclipse? [10:42]

<durkham> no not really, mine wont run because of that mysql problem :)
This guide describes how to setup a development environment in Eclipse for Stendhal.
<kymara> when one does ant dist for example you get a zip folder in

stendhal/build which i unzip in another folder [10:43]
== Get Java ==
<kymara> but i better not run that itn eclipse, that's froman old version

<durkham> how do you start the server normally? [10:44]
* If you can play Stendhal, you already have Java and can skip this step.
<kymara> i do ant dist and that makes a zipped file inside stendhal/build/
* If you do not have java installed, please download it https://java.com<br> (if you are on Linux, use your packet manager)
called something like stendhal-server-0.57.5.zip then i unzip that in

a 'server' folder then i type ./start.sh which sets my classpath and
== Get Node.js ==
starts the server [10:47]

<kymara> same when i want a new client i unzip
* https://nodejs.org (optional: for building & using web client)
stendhal/build/stendhal-0.57.5.zip ina client folder then the .jar i

need is tehre
== Get Eclipse==
<kymara> i looked at the file

src/games/stendhal/server/StendhalHTTPServer.java to see if running
* Go to https://www.eclipse.org/downloads/
that is all you need to do buyt i asked myboyfriend and he said
* Download: "Eclipse IDE for Java Developers"
because it doesn't have a word 'main' in it then it wouldn't be that
* Unzip the download and run Eclipse
one [10:50]
* In Eclipse, close the "Welcome" window
<durkham> in start.sh there must be written how the server is started [10:54]

<kymara> java -cp "${LOCALCLASSPATH}" marauroa.server.marauroad -c
You can click on the following images to see them in large.
marauroa.ini -l [10:58]

<hendrik> kymara, first of all make sure that the marauroa.ini is in your
<gallery>
stendhal project folder. [11:02]
File:Eclipse_00.png|On the first run of Eclipse, this "Welcome" window is shown. Please close it.
<hendrik> right click on your project folder and select "Properties" in the
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
context menu.
</gallery>
<hendrik> then select "Java Build Path" on the left side of the dialog box.
Note: If you installed Eclipse in Ubuntu via a package manager, also install: "eclipse-egit"
<hendrik> source folder: stendhal/src [11:04]

<hendrik> default output folder: stendhal/classes
== New Project from Git ==
<hendrik> On the "library" tab: [Add jars] and select all the files in

stendhal/libs [11:05]
In Eclipse:
<hendrik> eclipse should be able to compile the source code now.

<hendrik> there should be a little yellow sign before your project folder but
* Open menu "File -> Import
not red X. [11:06]
* In the dialog select: "Git -> Projects from Git" and click "Next".
<kymara> i think i see the project folder in the Navigator tab
* Select "Clone URI" and click "Next".
<kymara> shall i put marauroa.ini in stendhal/ ?
* Fill in the following information:
<kymara> it's not there yet
** '''URI''':
<hendrik> There is something called "Project Explorer" which is similar to the
*** 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)
nagivator.
*** GitHub read/write (SSH): <code><nowiki>git@github.com:arianne/stendhal.git</nowiki></code>
<hendrik> please copy it.
* The result of the fields are filled in automatically, click "Next"
<hendrik> please have a in detail look at the small icon in front of your
* On the Branch selection page, keep everything selected and click "Next"
project folder. [11:07]
* Under "Destination" choose the directory where you want to download the source code and select "Next".
<hendrik> is there a "J" in it?
* Eclipse will now download Stendhal from git, this may take a while
<kymara> I can't find Project Explorer to open but I can find Projects [11:08]
* "Import existing projects" and select "Next"
<kymara> in Projects I see a small J
* "Finish" import of project Stendhal
<kymara> but the projects tab doesn't have anything in it [11:09]

<kymara> only navigator does
Click on the screenshots to enlarge them, if you need help with any of the steps:
<kymara> there is something called Package Explorer

<hendrik> oh sorry,you are right. [11:11]
<gallery>
<kymara> i can make a new project
Eclipse 01.png|Open File | Import
<kymara> from an existing ant build
Eclipse 02.png|Import from Git
<hendrik> no, it is ok.
Eclipse 03.png|Clone URI
<hendrik> after you do the steps there should be "src" folder directly below
Eclipse 04.png|Fill in URI and watch the remaining fields to be filled automatically
the project folder in the package explorer. [11:12]
Eclipse 05.png|Just click "next" on branch selection
<CIA-21> arianne_rpg: astridemma *
Eclipse 06.png|Just click "next" on destination
stendhal/src/games/stendhal/client/entity/RPEntity.java: removed
Eclipse 07.png|Wait for the download to complete. This may take quite a while
unused imports [11:13]
Eclipse 08.png|Import existing project
<hendrik> do NOT create an ant project. [11:14]
Eclipse 09.png|Confirm import of project "Stendhal" by clicking finish
<kymara> i can't do the first thing you said [11:16]
</gallery>
<kymara> right click on your project folder and select "Properties" in the

<kymara> context menu.
==Trouble Shooting==
<kymara> there's nothing in my project folder [11:17]

<kymara> should i create a new project but not an ant one?
After completing the import wizard, Eclipse should look like the following screenshot:
<hendrik> is the package explorer empty? [11:18]

<hendrik> or do you see the directory tree there?
[[File:Eclipse 10.png]]
<kymara> i see directory tree in package explorer and navigator [11:19]

<hendrik> ok [11:20]
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.
<hendrik> with "project folder" i mean the top level entry.

<hendrik> in the package explorer.

<hendrik> the one with the blue folder icon [11:21]
== Start StendhalServer ==
<kymara> ok i will go back and follow your instructions now :)

<kymara> sleetcing properties doesn't show a 'Java build path' on the left. 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.
shows 'Builders' though [11:22]
[[File:Eclipse_debug_configurations_menu.png]]
<kymara> i think i only imported it as a cvs project so far? [11:23]
* This will open a menu, please choose "Debug configurations ..." ("Open Debug Dialog..." on older versions)
<hendrik> ok, it there a little blue "J" on the blue folder icon.
* Then in the dialog select "Java Application" and click on the "new" icon in the top left corner.
<hendrik> ?
[[File:Eclipse_new_debug_configuration.png]]
<kymara> no not on the one in package explorer

<kymara> it shows an orange square [11:25]
Name: StendhalServer
<hendrik> then you need to create a new "Java Project".
Main class: games.stendhal.server.StendhalServer
<kymara> Cannot create project content in workspace. [11:30]

<hendrik> did you use "file -> new project" or something else? [11:31]
* All other settings ("include system libries", "Stop in main", ... can be left at their default value.
<hendrik> does the old and new project folder tree overlap? [11:32]
* on the [Arguments] tab: VM arguments: -Xmx128M
<kymara> i deleted the old cvs project from eclipse but not the files then i
* on the [Classpath] tab: click "UserEntries" - button "Advanced" - (*) add folder | OK - and select the "stendhal" project root folder | OK
was trying to create a project from files and it didn't likeit
* button [Debug]
[11:33]

<kymara> but i got it working now properly
And then the server should be started.
<hendrik> Does the package explorer now display the "src" folder directly

below the root folder with a different icon? [11:35]
NOTE: On newer Eclipse versions, the [Classpath Entries] are under Dependencies tab.
<kymara> yes the icon is like a small grid [11:36]

<kymara> and i followed all the instructions about jars and output folders you
== Start Stendhal Client ==
said above
# Open games.stendhal.client.update.Starter.java in the editor
<kymara> oh but a little red cross just appeared
# Then again the small black arrow on the right side of the green bug.
<kymara> shall i tell you the errors? [11:37]
# Select "Debug Configurations" (or "Run Configurations...").
<hendrik> yes
# Select Java Application and click the "New" button in upper-left corner.
<kymara> it's to do with Entity.java
# On the [Classpath] tab select "User Entries" - button "Advanced" - (*) add folder | OK - and select the project root folder. | OK
<kymara> it wants java.lang.iterable it is indirectly referenced from required

.class files
== Making patches ==
<kymara> i'll add import blah to Entity.java? [11:38]

<hendrik> menu Windows | Preferences | Java | Installed JREs
If you have modified and tested the code and want to send us a patch, please see [[How To Create Patch For Stendhal]].
<hendrik> there should be at least one entry with a valid JAVA_HOME path

[11:39]
==Running JUnit Tests in Eclipse==
<kymara> i'm using teh wrong java vm

<kymara> adding better one now [11:40]
This is an advanced topic. If you make changes to the Java code, it is a good idea to run the automatic test.
<hendrik> there should be no more red X. [11:43]

<hendrik> if it does not change the error we may configure it in the project
Setting up JUnit tests in Eclipse:
preferences as well.
# Click the arrow next to either the green "Run" or "Debug" button.
<kymara> i have now made it so JDK compliance is 5.0 [11:46]
# Select "Run/Debug Configurations...".
*** ChadF (n=chadf@user-119a5l5.biz.mindspring.com) has joined channel #arianne
# Select "JUnit" in the left column and press the "New launch configuration" at the top of left column.
[11:47]
# Give it a unique name, like "Stendhal Tests".
<hendrik> is there still a red X?
# Select "Run all tests in the selected project, package or source folder".
<kymara> ChadF: i know the rejection message doesn't come up but i figured
# OPTIONAL: (this step simply reduces the number of directories that Eclipse will search in for tests)
while i was there i put it in for future use :P
## Press "Search".
<hendrik> or does it compile now?
## Select "tests" folder under Stendhal root directory and press "OK".
<kymara> hendrik: it's rebuilding the project 33%
# Under "Test runner" select "JUnit 4".
<kymara> it needs so many billions of heap space. i need a better computer
# Under "Classpath" tab select "User Entries" and press "Advanced" on the right panel.
[11:48]
#* NOTE: There should already be a folder under "User Entries" with a "(default classpath)" suffix. Do not delete this folder.
<kymara> there's still a red cross
# Select "Add Folders" and press "OK".
<ChadF> kymara: I know.. but still should make sure there aren't arbitrary
# Select the Stendhal root folder and press "OK".
line breaks in it (so it doesn't look bad if/when enabled), if you
# Now click "Add JARs..." on the right panel.
haven't already. [11:49]
# Under the Stendhal root folder select all the .jar files in libs and press OK.
<kymara> SeverityDescriptionResourceIn FolderLocationCreation TimeId
# Now press "Apply" to save the configuration or "Run" to save and run it.
<kymara> 2The method getLayerVector() is undefined for the type

MapMapConverter.javastendhal/src/games/stendhal/toolsline 111March 9,

2007 11:47:17 6552
[[Category:Stendhal]]
<kymara> ok ChadF
<hendrik> kymara, please ignore the stendhal/tools for the moment.
<hendrik> no, i rember the problem. [11:50]
<kymara> do i need to make sure it's not built with the project somehow?
<hendrik> please right click your project folder again --> properties -> java
build path.
<kymara> ok [11:51]
<hendrik> in the [source] tab there should only be stendhal/src
<hendrik> remove stendhal/tiled/src
<kymara> ok
<hendrik> this entry has higher priority than the tiled.jar in the libs folder.
<hendrik> but this code is highly outdated. [11:52]
<kymara> no little red crosses now :) only warnings :) [11:54]
<hendrik> very good. [11:55]
<hendrik> in the toolbar there is a green icon which looks like a bug.
<hendrik> there is a little black arrow on the right side of it. [11:58]
<hendrik> this will open a menu, please choose "Debug..."
<hendrik> then in the dialog select "Java Application" and click on the "new"
icon in the top left corner. [11:59]
<hendrik> Name: StendhalServer
<hendrik> Main class: marauroa.server.marauroad
<hendrik> [x] include libaries when searching for the main class [12:00]
<hendrik> on the [Arguments] tab:
<hendrik> Program arguments: -c marauroa.ini -l
<hendrik> on the [Classpath] tab:
<hendrik> button "Advanced" [12:01]
<hendrik> (*) add folder | OK
<hendrik> and select the root folder
<hendrik> OK
<hendrik> button [Debug]
<hendrik> and then the server should be started. [12:02]
<hendrik> i am going to the backery for some quick lunch. [12:03]
<kymara> ok
<hendrik> client will be easier.
<kymara> sorry
<kymara> my phone rang
<kymara> i'll read your instrustions
<hendrik> for the client: simply open games.stendhal.client.update.Starer.java
in the editor [12:04]
<hendrik> then again the small black arror on the right side ofthe green bug.
<hendrik> java application -> new-icon
<hendrik> and it should be prefilled.
<kymara> for ther server [12:11]
<kymara> i had to add the external mysql jar
<kymara> that i had in my other stendhal folder, then it is happy now
<hendrik> for the client the [Classpath] advanced root folder thingy is needed
as well. [12:13]
<durkham> :) this is the nicest explanation ever and arianne_eye is not running
<durkham> brb [12:14]
<kymara> shall i c&p and make a wiki guide out of this?
<hendrik> if it work, we can put it into the wiki tonight.
<durkham> oh yes that would be great [12:15]
<kymara> client! woo [12:16]
* ChadF sighs.. got the new motherboard's/cpu's yesterday, but the cases to go
with them won't arrive till Monday.
<kymara> pah you don' tneed a case
* ChadF will have fun testing the boards without cases =|
<kymara> yay shiny new client, shiny server