Using NetBeans with GameGardens

From Gardenwiki

Jump to: navigation, search

Here is one way to set up NetBeans 5.0 to work with GameGardens development and testing.

  1. File -> New Project -> General -> Java Project with Existing Ant Script
  2. For Location, browse to find the folder where the build.xml script for the game is located. This will be inside your GameGardens tree, in the <game> folder (where <game> is the name of the game).
  3. Defaults work on the rest of the boxes on this screen.
  4. For "run project" select "dist".
  5. Add the source package folder. Normally this will be src\java .
  6. Set the source level to JDK 1.5
  7. Click Add JAR, and browse to find the games\lib folder. Add each of the library jar files.
  8. Click Finish
  9. Open build.xml and copy the CLIENT section, which looks like this:
 <target name="client">
   <fail unless="username">
     Please specify a username: ant -Dusername=who client
   </fail>
   <java classname="com.threerings.toybox.client.ToyBoxApp" fork="true">
     <classpath>
       <pathelement location="${deploy.dir}/classes"/>
       <pathelement location="../client/gg-client.jar"/>
     </classpath>
     <sysproperty key="no_log_redir" value="true"/>
     <arg value="localhost"/>
     <arg value="47624"/>
     <arg value="${username}"/>
     <arg value="secret"/>
   </java>

Add copies of the CLIENT section, with the "fail" section removed and the username specified. To be able to test with three clients in the same game, make three clients. Here is the code for the first client:

 <target name="client1">
   <java classname="com.threerings.toybox.client.ToyBoxApp" fork="true">
     <classpath>
       <pathelement location="${deploy.dir}/classes"/>
       <pathelement location="../client/gg-client.jar"/>
     </classpath>
     <sysproperty key="no_log_redir" value="true"/>
     <arg value="localhost"/>
     <arg value="47624"/>
     <arg value="one"/>
     <arg value="secret"/>
   </java>
 </target>

client2 and client3 are similar - just change "client1" and "one".

  1. Next, in the Project window, right-click on the name of the Project, which will have an Ant icon. Select Properties -> Build and Run.
  2. In Custom Menu Items, add an Ant target first for the server, and then for each of the new client sections you added. To be able to test using three players at once, add server, client1, client2, and client3. Just click under "Ant Target" after you click "Add" and then use the dropdown menu to find your target.

At this point, NetBeans is configured for you. If you have NetBeans, then you already know how to edit the source code, and pressing F6 will run "ant dist". To run the game from the Project window, right-click on the name of the project, and select "server". When the server is listening, right-click again and select one of the clients. Have the first client make a game table, then fire up the rest of your clients.

When you finish playing, you will need to use the Runtime window, Processes to terminate execution of the server.

Note: Don't forget that you need to "run" the project to do "Ant dist", not just "Clean and Build". The server will not run correctly if the call to ant dist isn't done first.

Personal tools