2012-01-17 50 views
2

我目前正在開發使用NetBeans 6.9.1的應用程序,但是當我嘗試運行該程序,我收到以下錯誤KXML從網站

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」爲空,我該如何解決?

我也把網址中的字符串URL像這樣:

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

但是這不應該的問題作爲第一種方式有一個默認的網址去。

有人知道我在做什麼錯嗎?

回答

0

這有幫助嗎?

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

如果你指的是文章Parsing XML in J2ME,你應該知道它是從2002年,從那時起KXML擁有先進的。

如果您處於不幸的情況下才能使midlet運行,則此documentation可能會對您有所幫助。恕我直言,你需要通過在清單文件中設置屬性名稱RSSMIDlet.URLhttp://wwww.anything.com來配置midlet。

+0

但是,您如何將RSSMIDlet.URL的屬性名稱設置爲url? – 2012-01-17 13:45:45

+0

文章「檢索MIDlet屬性」(第二個鏈接)應該會對您有所幫助。它指出:[...] JAR文件包含一個清單/META-INF/MANIFEST.MF,它是一個特殊的文件,包含AMS和MIDlet等屬性信息。 – remipod 2012-01-17 14:49:36