Im a n00b with mobile Java and wold like to ask you all for help.
I use Eclipse 3.4.1 with eclipseME. I use Nokia 6131 NFC SDK (ver. 1.1).
I encountered following problem. While trying to read a file I constanly get NullPointerException ( run this in the emulator in Real Life security level).
My code:
This is what i get in the concole:Code:/** * */ package main; import java.io.IOException; import java.util.Enumeration; import javax.microedition.io.Connector; import javax.microedition.io.file.FileConnection; import javax.microedition.io.file.FileSystemRegistry; import javax.microedition.lcdui.*; import javax.microedition.midlet.*; //import tagreading.TagFoundListener; /** * @author Grzegorz Gwozdz */ public class NFCMIDlet extends MIDlet { private Display display; /** * */ public NFCMIDlet() { display = Display.getDisplay(this); } /** * @see javax.microedition.midlet.MIDlet#destroyApp(boolean) */ protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { } /** * @see javax.microedition.midlet.MIDlet#pauseApp() */ protected void pauseApp() { } /** * @see javax.microedition.midlet.MIDlet#startApp() */ protected void startApp() throws MIDletStateChangeException { System.out.println("FileConnection ver.:"+ System.getProperty("microedition.io.file.FileConnection.version")); Enumeration roots = FileSystemRegistry.listRoots(); while(roots.hasMoreElements()){ System.out.println(roots.nextElement()); } try { FileConnection fileConnection = (FileConnection)Connector.open("file:///e:/"); } catch (IOException ex) { ex.printStackTrace(); } catch (NullPointerException e){ System.out.println("Error:"+e.getMessage()); e.printStackTrace(); } } }
Emulator command: E:\Nokia\Devices\Nokia_6131_NFC_SDK_1_1\bin\midp.exe -Xdescriptor "C:\DOCUME~1\marta\USTAWI~1\Temp\_eclipseme.tmpmarta\NFCTest4791668885001017552.launch\NFCTest.jad"
FileConnection ver.:1.0
c:/
e:/
Error:null
java.lang.NullPointerException
Fancy, same code (with 'e:' switched to 'root1') works fine with Sun Java Wireless Toolkit 2.5 for CLDC emulator).
Can you please tell me what i am doing wrong?

Reply With Quote
So far im using the emulator provided with Nokia 6131 NFC SDK.


