Tuesday, December 14, 2010

SmartFoxServer Project Creation - Extension and Entity

Last time we left off we now had a working web server and had Smart Fox Server up and running with OpenJPA ready to be used. Now we are going to cover setting up our Java Extension for Smart Fox Server.

Creating our Extension and Entity Projects

Start by opening Netbeans. Here we will want to create 2 new Java Class Libraries.

We don't care where these projects are. I name them [GameName]Entities and [GameName]Extension.

So now you will have 3 projects, [GameName] (php), [GameName]Entities and [GameName]Extension (java). Next we need to reference a new library set. Open up the [GameName]Entities project and right-click Library and click Properties. The compile tab will start empty:
  1. Click Add Library...
  2. Click Create...
  3. Name it SmartFoxServer and leave it as Class Libraries type.
  4. Click OK.
  5. Click Add JAR/Folder...
  6. Navigate to [SFSInstallDir]\SFS2X\lib and select sfs2x.jar and sfs2x-core.jar
  7. Hit Add JAR/Folder to close the window.
  8. Hit Add JAR/Folder...
  9. Navigate to [OpenJPADir] and select openjpa-all-2.0.1.jar
  10. Hit Add JAR/Folder to close the window.
  11. Hit Add JAR/Folder...
  12. Navigate to [OpenJPADir]\lib and select ALL .jar files
  13. Hit Add JAR/Folder to close the window.
  14. Hit OK to create the library.
  15. Scroll through the list of Available Libraries and select SmartFoxServer
  16. Hit Add Library to close this window.
  17. Click OK to close the project properties window.
You will want to follow steps 1, 15, 16, and 17 and select both SmartFoxServer and MySQL JDBC Driver.
Before you close the Project Properties window for the Extension project, you will also want to click Add Project and navigate to your [GameName]Entities project and click Add Project JAR Files.

This will give you the setup you will use for your entities and extension in Smart Fox Server.


No comments: