Flash Multiplayer Virtual World with SmartFoxServer Using Embedded Web Server and Database

Build immersive, full-featured interactive worlds for games, online communities, and more

(For more resources on Flash, see here.)

Unlike a deployment environment, it is common to have just once machine acting both as server and client in a development environment. The machine will have SmartFoxServer, web server, and database installed. In this case, there are no noticeable differences between using the embedded or third-party web server and database.

It is a good habit to simulate the deployment environment as much as possible in development stage. As we are going to use a third-party web server and database, we will set up a development environment that also uses the third-party server instead of the embedded web server and database in the third part of this article series.

Installing Java Development Kit

The Java Development Kit includes the essential development tools (JDK) and the Java Runtime Environment (JRE). The development tool compiles the Java source code into byte codes and the JRE is the response to execute the byte codes. We will need several Java compilations in later chapters. SmartFoxServer is build on the Java environment and we need the JRE to start up the server. The JDK and JRE may be pre-installed in some OSs.

Installing JDK On Windows

The steps for installing JDK on Windows are as follows:

  1. Go to http://java.sun.com/javase/downloads/.
  2. Click on the Download button of Java. It will lead to the Java SE Downloads page.

  3. Select Windows (or Windows x64 for 64-bits Windows) in Platform.
  4. Click on Download.
  5. If it prompts an optional login request, we can click the Skip this Step to bypass it.
  6. Launch the installer after the download.
  7. Install the Java Development Kit with all default settings.
  8. The Java environment is ready after installation completes.

Installing JDK on Mac OSX

The Mac OSX comes with its own set of Java environment. We can check the JDK and JRE version by following steps:

  1. Launch terminal from Applications | Utilities | Terminal.
  2. Type the following and press the Enter key:

    javac -version

  3. The command will output the currently installed version of the Java in the Mac OSX. In my case, it outputs: javac 1.6.0_17.

The current version of SmartFoxServer at the time of writing recommends the version 1.6. If the Java is not updated, we can update it via Apple Menu | Software Update.

The software update will check for any updates for your existing Mac software, including the Java environment.

Installing JDK on Linux

We can use the general method to download and install the JDK or use the system specific method to install the package. We will show the general method and the Ubuntu method.

Installing for General Linux

  1. Go to http://java.sun.com/javase/downloads/index.jsp in browser.
  2. Click on the Download button.
  3. The platform Linux should be selected automatically. Otherwise, select Linux (or Linux x64 for 64-bit Linux).
  4. Click on Continue.
  5. If it prompts for login, click on Skip this Step to bypass it.
  6. For Redhat or Fedora Linux, choose the rpm-bin file to download. For other Linux, choose the .bin file to download.
  7. Launch terminal via Applications | Accessories | Terminal after the download completes.
  8. Change the directory to the folder that contains the downloaded package. The download destination varies from different profile settings. In my case, it is in Downloads folder.

    cd ~/Downloads/

  9. The version is Java 6 Update 20 at the time of writing and the filename is jdk-6u20-linux-i586.bin or jdk-6u20-linux-i586-rpm.bin.
  10. Then we make it executable and launch the installer by the following commands:

    chmod a+x jdk-6u20-linux-i586.bin


  11. The installer displays the license agreement. Type Yes at the end to agree and continue installation.
  12. Press the Enter key after the file’s extraction to end the installation.

Installing for Ubuntu Linux

Ubuntu users can install the JDK via the apt-get command.

  1. We will search for the latest package name of the JDK by the following command:

    apt-cache search --names-only sun-java.*-jdk

  2. The result shows the available JDK packet names. At the time of writing, it is JDK6:

    sun-java6-jdk - Sun Java(TM) Development Kit (JDK) 6

  3. We use the apt-get command to install the JDK:

    sudo apt-get install sun-java6-jdk

  4. Type in the user password because it requires user’s password and the privilege to use apt-get.

(For more resources on Flash, see here.)

Downloading SmartFoxServer Pro

We are going to walkthrough the installation of SmartFoxServer Pro and third-party web server and database in all supported platforms.

For Windows, Mac OS, and Linux that have a graphic user interface, you can follow these steps to download the SmartFoxServer Pro:

  1. Go to http://www.smartfoxserver.com/products/pro.php#downloads in web browser.
  2. Select the OS platform. We will use Windows 32-bit as an example here.
  3. The download will start after clicking on the Download button.

For Linux platform that does not have a graphic user interface, you can follow these steps to download the SmartFoxServer Pro Linux x86-32-bit version:

  1. Go to the directory that planned to place the SmartFoxServer.
  2. Type the following line in the terminal to download the file:

    wget http://www.smartfoxserver.com/products/download.php?d=76

  3. The download will start after pressing the Enter key.

For a Linux platform that does not have graphic user interface, you can follow these steps to download the SmartFoxServer Pro Linux x86-64-bit version:

  1. Go to the directory that planned to place the SmartFoxServer.
  2. Type the following line in the terminal to download the file:

    wget http://www.smartfoxserver.com/products/download.php?d=77

  3. The download will start after pressing the Enter key.

Installing SmartFoxServer Pro

The installation process is different from SmartFoxServer for Windows, Linux, and Mac OS.

Installing on Windows

  1. Run the installer SFSPRO_win_1.6.6.exe.
  2. When asked for the installation path we change the install path to any directory under the user folder, such as C:\Users\username\SmartFoxServerPRO_1.6.6.

We change the installation path instead of the default path under Program Files because latest Windows requires administrator privileges to change the files.

Installing on Mac OSX

  1. After downloading the SmartFoxServer, it will be automatically mounted.
  2. Open the Applications folder.
  3. Drag the SmartFoxServer Pro 1.6.6 folder into Applications.

Installing on Linux

  1. Launch the terminal from Applications | Accessories | Terminal.
  2. Go to the enclosing folder of the SFSPRO_linux_1.6.6.tar.gz.
  3. Type following command in the terminal to decompress the tar:

    tar zxf SFSPRO_linux_1.6.6.tar.gz

Running the SmartFoxServer

There are different ways to run the SmartFoxServer in different platforms.

Starting SmartFoxServer on Windows

The SmartFoxServer can be launched from the start menu. Click on Start | Programs | SmartFoxServerPro_1.6.6 | Start SmartFoxServer.

A command prompt will then appear and it shows up logs of loading different modules. Error messages may appear if there is any error that fails to start up the server.

Starting SmartFoxServer on Mac OS

The server launcher is located in Applications | SmartFoxServer Pro 1.6.6 | SmartFoxServer.app. Double-click to launch it and it will also display the log in a window.

Starting SmartFoxServer on Linux

  1. Launch terminal from Applications | Accessories | Terminal.
  2. Go to the SmartFoxServer installation folder | Server.
  3. Type the following command in the terminal to launch the server:


Using embedded web server and database

We are going to play with the embedded web server and database. The embedded web server and database are well-configured and run on startup by default. This lets developers rapidly develop the prototype of the virtual world without worrying about setting up different servers.

Running the embedded web server

By default, the web server is running on port 8080 with same SmartFoxServer location.

After starting up the SmartFoxServer, go to http://localhost:8080 in the web browser. If a webpage shows up with a message "SmartFoxServer Pro 1.6.6 is installed successfully", it means the server is working with default settings.

The HTTP documents directory of the embedded server is located in Installation folder | Server | webserver | webapps | root. You can modify and store static web pages within this folder to host the virtual world website.

Running the embedded database server

The embedded H2 database server is well-configured upon SmartFoxServer installation.

Windows users can launch the H2 Database Admin Tool by double-clicking the adminDB.bat, which is located in SmartFoxServer installation directory | Server. Linux and Mac users can launch by executing the following command in the terminal in the Server directory:

chmod +x adminDB.sh


After executing the adminDB script, a web interface of the Admin tool will open in browser.

We will use the default saved settings to connect the H2 database. In Windows and Linux, the default setting is Generic H2, while in Mac, the setting is called Generic H2 (Embedded).

If the development is based on H2 Database engine, we can test the database by clicking the Connect button with default settings.

After connected to the H2 database engine, the admin panel is divided into three parts. The upper part contains action buttons for operating the database such as the logout or execute commands. The left part lists all available users and tables. The right part is for inputting the SQL commands and viewing the results. H2 database is a light-weight engine that we need to operate the database by typing all the SQL commands ourselves.


In this article we covered running SmartFoxServer using embedded web server and database. In ths next article we will deal with SmartFoxServer together with third-party web servers and databases, for example, Apache and MySQL.


Further resources on this subject:

Books to Consider

Flash Game Development by Example
$ 21.60
Flash Multiplayer Virtual Worlds
$ 29.99
Getting Started with Microsoft Application Virtualization 4.6
$ 32.99
Getting Started with SQL Server 2014 Administration
$ 16.99
comments powered by Disqus

An Introduction to 3D Printing

Explore the future of manufacturing and design  - read our guide to 3d printing for free