Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 136849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:00:48+00:00 2026-05-11T07:00:48+00:00

I am trying to compile the code from here: http://www.brackeen.com/javagamebook/#download (Chapter 6) and am

  • 0

I am trying to compile the code from here: http://www.brackeen.com/javagamebook/#download (Chapter 6) and am having trouble. I don’t understand how java.util.logging.Logger and log4j work together, but that seems to be the issue. The errors I get are all on the log.error() or log.warn() method calls.

Here is the output from NetBeans:

 init: deps-clean: Deleting directory C:\JB\NetBeansProjects\WRServer\build Deleting directory C:\JB\NetBeansProjects\WRServer\dist clean: init: deps-jar: Created dir: C:\JB\NetBeansProjects\WRServer\build\classes Compiling 23 source files to C:\JB\NetBeansProjects\WRServer\build\classes C:\JB\NetBeansProjects\WRServer\src\com\hypefiend\javagamebook\server\GameServer.java:110: cannot find symbol symbol  : method error(java.lang.String,java.lang.Exception) location: class java.util.logging.Logger             log.error('error initializing ServerSocket', e);                ^ C:\JB\NetBeansProjects\WRServer\src\com\hypefiend\javagamebook\server\GameServer.java:152: cannot find symbol symbol  : method warn(java.lang.String) location: class java.util.logging.Logger                 log.warn('error during serverSocket select(): ' + ioe.getMessage());                    ^ C:\JB\NetBeansProjects\WRServer\src\com\hypefiend\javagamebook\server\GameServer.java:155: cannot find symbol symbol  : method error(java.lang.String,java.lang.Exception) location: class java.util.logging.Logger                 log.error('exception in run()', e);                    ^ C:\JB\NetBeansProjects\WRServer\src\com\hypefiend\javagamebook\server\GameServer.java:187: cannot find symbol symbol  : method error(java.lang.String) location: class java.util.logging.Logger             log.error('no gamecontroller for gameNameHash: ' + gameNameHash);                ^ C:\JB\NetBeansProjects\WRServer\src\com\hypefiend\javagamebook\server\GameServer.java:203: cannot find symbol symbol  : method error(java.lang.String) location: class java.util.logging.Logger             log.error('error getting GameController directory');                ^ C:\JB\NetBeansProjects\WRServer\src\com\hypefiend\javagamebook\server\GameServer.java:223: cannot find symbol symbol  : method warn(java.lang.String) location: class java.util.logging.Logger                     log.warn('class file does not extend GameController: ' + file);                        ^ C:\JB\NetBeansProjects\WRServer\src\com\hypefiend\javagamebook\server\GameServer.java:238: cannot find symbol symbol  : method error(java.lang.String,java.lang.Exception) location: class java.util.logging.Logger                 log.error('Error instantiating GameController from file: ' + file, e);                    ^ Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 7 errors BUILD FAILED (total time: 0 seconds) 

Here is the code straight from the book. I have not tried to edit it yet.

package com.hypefiend.javagamebook.server;  import com.hypefiend.javagamebook.common.*; import com.hypefiend.javagamebook.server.controller.*;  import java.nio.channels.*; import java.util.*; import java.net.*; import java.io.*; import java.util.logging.Logger; import org.apache.log4j.*;  /**  * GameServer.java  *  * The heart of the framework, GameServer accepts  * incoming client connections and hands them off to   * the SelectAndRead class.  * GameServer also keeps track of the connected players  * and the GameControllers.  *  * @author <a href='mailto:bret@hypefiend.com'>bret barker</a>  * @version 1.0  */ public class GameServer extends Thread { /** log4j Logger */ private Logger log = Logger.getLogger('GameServer');  /** ServerSocketChannel for accepting client connections */ private ServerSocketChannel sSockChan;  /** selector for multiplexing ServerSocketChannels */ private Selector selector;  /** GameControllers keyed by GameName */ private Hashtable gameControllers;  /** classname prefix used for dynamically loading GameControllers */ private static final String CONTROLLER_CLASS_PREFIX =  'com.hypefiend.javagamebook.server.controller.';  /** players keyed by playerId */ private static Hashtable playersByPlayerId;  /** players keyed by sessionId */ private static Hashtable playersBySessionId;  private boolean running; private SelectAndRead selectAndRead; private EventWriter eventWriter;  private static long nextSessionId = 0;  /**  * main.   * setup log4j and fireup the GameServer  */ public static void main(String args[]) { BasicConfigurator.configure(); GameServer gs = new GameServer(); gs.start(); }  /**  * constructor, just initialize our hashtables  */ public GameServer() { gameControllers = new Hashtable(); playersByPlayerId = new Hashtable(); playersBySessionId = new Hashtable(); }  /**  * init the GameServer, startup our workers, etc.  */  public void init() { log.info('GameServer initializing');  loadGameControllers(); initServerSocket();  selectAndRead = new SelectAndRead(this); selectAndRead.start();  eventWriter = new EventWriter(this, Globals.EVENT_WRITER_WORKERS);  }  /**  * GameServer specific initialization, bind to the server port,  * setup the Selector, etc.  */ private void initServerSocket() { try {     // open a non-blocking server socket channel     sSockChan = ServerSocketChannel.open();     sSockChan.configureBlocking(false);      // bind to localhost on designated port     InetAddress addr = InetAddress.getLocalHost();     log.info('binding to address: ' + addr.getHostAddress());     sSockChan.socket().bind(new InetSocketAddress(addr, Globals.PORT));      // get a selector     selector = Selector.open();      // register the channel with the selector to handle accepts     SelectionKey acceptKey = sSockChan.register(selector, SelectionKey.OP_ACCEPT); } catch (Exception e) {     log.error('error initializing ServerSocket', e);     System.exit(1); } }  /**  * Here's the meat, loop over the select() call to   * accept socket connections and hand them off to SelectAndRead  */ public void run() { init(); log.info('******** GameServer running ********'); running = true; int numReady = 0;  while (running) {     // note, since we only have one ServerSocket to listen to,     // we don't need a Selector here, but we set it up for      // later additions such as listening on another port      // for administrative uses.     try {     // blocking select, will return when we get a new connection     selector.select();      // fetch the keys     Set readyKeys = selector.selectedKeys();      // run through the keys and process     Iterator i = readyKeys.iterator();     while (i.hasNext()) {         SelectionKey key = (SelectionKey) i.next();         i.remove();          ServerSocketChannel ssChannel = (ServerSocketChannel) key.channel();         SocketChannel clientChannel = ssChannel.accept();          // add to the list in SelectAndRead for processing         selectAndRead.addNewClient(clientChannel);         log.info('got connection from: ' + clientChannel.socket().getInetAddress());     }            }     catch (IOException ioe) {     log.warn('error during serverSocket select(): ' + ioe.getMessage());     }     catch (Exception e) {     log.error('exception in run()', e);     } } }  /**   * shutdown the GameServer  */ public void shutdown() { selector.wakeup(); }  /**  * Return the next available sessionId  */ public synchronized String nextSessionId() { return '' + nextSessionId++; }  /**  * finds the GameController for a given GameName  */ public GameController getGameController(String gameName) { return getGameControllerByHash(gameName.hashCode()); }  /**  * finds the GameController for a given GameName hash code  */ public GameController getGameControllerByHash(int gameNameHash) { GameController gc = (GameController) gameControllers.get('' + gameNameHash); if (gc == null)      log.error('no gamecontroller for gameNameHash: ' + gameNameHash); return gc; }  /**  *  Dynamically loads GameControllers  */ private void loadGameControllers() { log.info('loading GameControllers');  // grab all class files in the same directory as GameController String baseClass = 'com/hypefiend/javagamebook/server/controller/GameController.class'; File f = new File( this.getClass( ).getClassLoader().getResource(baseClass).getPath()); File[] files = f.getParentFile().listFiles( );  if (files == null) {     log.error('error getting GameController directory');     return; }  for( int i = 0; ( i < files.length); i++) {     String file = files[i].getName( );     if (file.indexOf( '.class') == -1)     continue;     if (file.equals('GameController.class'))     continue;      try {     // grab the class     String controllerClassName = CONTROLLER_CLASS_PREFIX + file.substring(0, file.indexOf('.class'));     log.info('loading class: ' + controllerClassName);      Class cl = Class.forName(controllerClassName);      // make sure it extends GameController     if (!GameController.class.isAssignableFrom(cl)) {         log.warn('class file does not extend GameController: ' + file);         continue;     }      // get an instance and initialize     GameController gc = (GameController) cl.newInstance();     String gameName = gc.getGameName();     gc.init(this, getGameConfig(gameName));      // add to our controllers hash     gameControllers.put('' + gameName.hashCode(), gc);      log.info('loaded controller for gameName: ' + gameName + ', hash: ' + gameName.hashCode());     }      catch (Exception e) {     log.error('Error instantiating GameController from file: ' + file, e);     } } }   /**  * pass the event on to the EventWriter  */ public void writeEvent(GameEvent e) { eventWriter.handleEvent(e); }  /**  * returns the GameConfig object for the given gameName  */ public GameConfig getGameConfig(String gameName) { // todo: implement getGameConfig() return null; }  /**  * fetches the Player for a given playerId  */ public static Player getPlayerById( String id) { return (Player) playersByPlayerId.get(id); }  /**  * fetches the Player for a given sessionId  */ public static Player getPlayerBySessionId(String id) { return (Player) playersBySessionId.get(id); }  /**   * add a player to our lists  */ public static void addPlayer(Player p) { playersByPlayerId.put(p.getPlayerId(), p); playersBySessionId.put(p.getSessionId(), p); }  /**  * remove a player from our lists  */ public static void removePlayer(Player p) { playersByPlayerId.remove(p.getPlayerId()); playersBySessionId.remove(p.getPlayerId()); }  }// GameServer 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:00:49+00:00Added an answer on May 11, 2026 at 7:00 am

    The import of java.util.logging.Logger in your class seems to cause the problem (the compiler tries to compile against that one, altough it seems the intention was to use the log4j Logger class).

    Try to remove the java.util.logging.Logger from the imports and recompile.

    EDIT: Well, I just checked the original GameServer.java from the ZIP file linked in the page linked in the question. it does NOT contain any import of java.util.logging.Logger there. My guess is thus:

    • You do not have log4j on the classpath of your project
    • You or your IDE tried to somehow organize the imports automatically. This ended up adding java.util.logging.Logger to the imports because no other class of that name was found in project’s classpath.

    So, add log4j to the classpath first, then remove the java.util.logging.Logger from the imports.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Download the source code with compiled executable here (Size: 161 KB (165,230 bytes)): http://www.eyeClaxton.com/download/delphi/ColorSwap.zip
I was trying to make a sample code run download by the link http://www.magtek.com/support/software/downloads/sw/99510108.zip
I'm currently trying to compile some code examples from http://developer.gnome.org/gtkmm-tutorial/unstable/sec-treeview-examples.html.en but from what I
I'm trying to compile in Eclipse the example code from McDowell here JNA Keyboard
I'm trying to apply the technique described in http://www.drdobbs.com/tools/227500449 With the sample code below,
I'm trying to compile Q4M ( http://q4m.31tools.com ) for MySql 5.1.44 since there is
I'm trying to compile and run the task-android-sample code from Google's API website. I
hI, I'm trying to get this code from Larry Nyhoff's book to compile in
Currently I am trying to compile native code for Android. The code is from
Backgound steps Used Mozilla code from here: http://mxr.mozilla.org/seamonkey/source/modules/plugin/tools/sdk/samples/basic/windows/ New Empty Project in Visual Studio

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.