java.util.logging.Logger and log4j

后端 未结 3 1394
礼貌的吻别
礼貌的吻别 2021-01-14 08:51

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.

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-14 09:06

    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.

提交回复
热议问题