Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading a resource file

 
Sathya Srinivasan
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to read a resource file from the jar that I deployed in a phone. I am using the following piece of code to read the resource file.

When I tried to compile this code in JBuilder (with MobileSet), it gives the following error.

"JumbleRecord.java": Error #: 302 : cannot access class java.lang.NoClassDefFoundError; java.io.IOException: class not found: class java.lang.NoClassDefFoundError
Error #: 2301 : internal compiler error: java.lang.ClassCastException

After a bit of investigation, I found that the ClassNotDefFoundError class was not in the midp.jar file, but was in cldc.jar file and that the J2ME configuration did not have the CLDC file.
When I tried to include the file, I got more absurd errors.
When I tried to compile the file without JBuilder, I was able to create a .jar file successfully, but when I ran it on an emulator, it gave a similar error.
Has anyone encountered a similar problem?? Or am I doing something fundamentally wrong in trying to access a resource file?
Any help greatly appreciated!
 
Pavlin Mihalev
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
Try to put an "/" in your path:
getResourceAsStream("/xxx.txt");
Cheers,
Pavlin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic