2

現在、netbeans 6.9.1 を使用してアプリケーションを開発しようとしていますが、プログラムを実行しようとすると、次のエラーが発生します。

Uncaught exception: java.lang.IllegalArgumentException
    at javax.microedition.io.Connector.openPrim(), bci=31
    at javax.microedition.io.Connector.open(), bci=3
    at javax.microedition.io.Connector.open(), bci=3
    at javax.microedition.io.Connector.open(), bci=2
    at RSSParser$1.run(RSSParser.java:32)

このエラーはこのコードから来ています

public void parse(final String url) {
Thread t = new Thread() {
  public void run() {
    // set up the network connection
    HttpConnection hc = null;

    try {
      hc = (HttpConnection)Connector.open(url);
      parse(hc.openInputStream());
    }
    catch (IOException ioe) {
      mRSSListener.exception(ioe);
    }
    finally {
      try { if (hc != null) hc.close(); }
      catch (IOException ignored) {}
    }
  }
};
t.start();
}

このメソッドは、ここで別のクラスから呼び出されています

public void startApp() {
if (mDisplay == null)
  mDisplay = Display.getDisplay(this);

if (mInitialized == false) {
  // Put up the waiting screen.
  Screen waitScreen = new Form("Connecting...");
  mDisplay.setCurrent(waitScreen);
  // Create the title list.
  mTitleList = new List("Headlines", List.IMPLICIT);
  mExitCommand = new Command("Exit", Command.EXIT, 0);
  mDetailsCommand = new Command("Details", Command.SCREEN, 0);
  mTitleList.addCommand(mExitCommand);
  mTitleList.addCommand(mDetailsCommand);
  mTitleList.setCommandListener(this);
  // Start parsing.
  String url = getAppProperty("RSSMIDlet.URL");
  RSSParser parser = new RSSParser();
  parser.setRSSListener(this);
  parser.parse(url);
  mInitialized = true;
}
else
  mDisplay.setCurrent(mTitleList);
}

デバッグすると、「String url」が null であると表示されます。これを解決するにはどうすればよいですか?

また、次のように文字列 url に url を入れました。

String url = getAppProperty("RSSMIDlet.http://wwww.anything.com");
String url = getAppProperty("http://wwww.anything.com");

ただし、最初の方法にはデフォルトの URL があるため、これは問題ではありません。

ここで私が間違っていることを誰かが知っていますか?

4

1 に答える 1

0

これは役に立ちますか?

String url = "http://wwww.anything.com";

Parsing XML in J2MEという記事を参照する場合、それは 2002 年のものであり、kxml はそれ以来進歩していることに注意してください。

残念ながら midlet を実行できない状況にある場合は、このドキュメントに興味があるかもしれません。IMHO 、マニフェスト ファイルでプロパティ名RSSMIDlet.URLhttp://wwww.anything.comに設定して、midlet を構成する必要があります。

于 2012-01-17T13:21:46.057 に答える