How to edit DimensioneX sources with Sun's NetBeans
KB Article n. 020
This article explains how to open, edit, debug the java sources of the DimensioneX game engine. The reader needs to be familiar with the Java language.
Importing DimX into NeatBeans, running it
1. Make a copy of the dimx folder, in say, D:\dimxdev
2. In the dimxdev/WEB-INF subfolder, delete the file web.xml.
3. In the dimxdev/WEB-INF subfolder, rename the file web_netbeans_351.xml to: web.xml to make it useable by NetBeans.
4. Download and Install Net Beans 3.5.1 for free from our members section or from its original site: www.netbeans.org (warning - from original site you might find just the latest version of NetBeans, and these instructions may not work on it).
5. Run NetBeans
6. In NetBeans, Runtime Window (menu: View Runtime), under Server Registry->Installed Servers->Tomcat->Internal Tomcat right click and then choose Configure. In the editing window edit line 10 so that the port number is changed from 8081 to 8080. Save and close the server config file.
7. Again. in NetBeans, Explorer window (filesystems), right click filesystems, Mount->Local directory and select the new dimxdev folder you have created in step1
Now you should see a confirmation message box, click OK, then in your explorer window two more mounted filesystems will show up: The first is the shortcut to the whole development web tree D:dimxdev - the second is the shortcut to the java classes only (this one is actually a subset of the former, for your convenience)
8. In the first mounted tree, D:dimxdev, locate the WEB-INF node, right click and choose Properties edit the ContextRoot, enter /dimx then hit ENTER and close the properties pane
9. Now it's time for a test run. Click the first mounted tree, D:dimxdev, right click and choose Deploy, then right click and choose Execute. This operation will run the default dimx website, thus opening multiplayer class which by default will load the game slot #1: The Beach. Please note that this is just a test, NOT a method to run in debug mode. To finish the test, go to the Execution window (bottom right), right click "Internal tomcat", Terminate process.
10. In the second mounted dimxdev tree, open the nodes: cleoni and adv so to browse project classes. Right click multiplayer and choose Tools->Set as project main class. This choice selects the servlet for debugging when issuing a Debug command.
11: to debug (step - by - step execution), just use the menu: Project->Debug project. See also below
Producing a custom version of DimensioneX
Open the dimxdev: WEB-INF/classes folder, then open cleoni/adv then double click multiplayer. Try editing the version number property in the code: i.e. edit this one:
private static String myVersion = "5.1.5 custom";
Try now: menu: Project->Build Project, Debug Project. You will see that the version number has now changed.
However, if you want to start exploring code where it all begins just go to the method named: "service".
Debugging the code (step-by-step execution)
menu: Project->Build Project, Debug Project
To debug, Just set a breakpoint in the code (i.e. the beginning of multiplayer.service) before starting a debug session. You do this simply by opening the class, selecting the code of the service function from the drop-down, and clicking on the left margin. A pink square will appear on the margin. The execution will stop at the selected point and you can debug step-by step while playing (see picture below).
Here are some hints for troubleshooting:
If the debugging doesn't work, "resource not available" error. This is usually because the servlet mapping is wrong and needs to be fixed. We have two methods:
While the main project servlet is selected, check that its properties which are displayed in the bottom-left of the screen. There should be a property named: URI should be of the form: /servlet/multiplayer. You will need to edit this value by hand.
Select the main servlet multiplayer. Right click, cancel servlet and then again mark as servlet. In the following window: Process all. Now the IDE has created a mapping for multiplayer suitable for debugging. The automatic servlet mapping will be:
This mapping is clearly different but should work, too.
More useful settings
Here are more, useful setting I use for workng on thegame engine. I strongly recommend them.
We hope this article was clear enough and useful to you developers out there.
For any questions/doubts always feel free to ask by posting on the Developers' Pub forum. Try to give as much details as you can about your system and about what exactly does not work, which messages you see, etc.