1

我在appletviewer 中运行一个小applet 游戏,并且我有另一个java 程序定期尝试从applet 中获取'score' 字段。

但是现在我尝试这样做的方式是(稍微伪代码化):

小程序 myGame = Game();

Runtime.exec("appletviewer 游戏");

score = myGame.getCurrentScore;

问题是我初始化的applet变量与appletviewer创建的Applet不对应。我该如何解决这个问题?

4

1 回答 1

2

You wouldn't be able to do that. A few options:

  1. Write your information out to a file periodically to be read in by your secondary process.
  2. Write your information to a database to be read by your secondary process.
  3. Rearchitect your game to be called entirely from your secondary process so it has access to its memory. (So instead of using exec, be like myGame.startGame().)
于 2011-08-29T22:44:35.527 回答