MIDlet Runtime error Imported libraries not included in package build
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sean_R
Posted On:   Wednesday, August 10, 2005 08:20 AM

To anyone that can help me, I have developed an application in J2ME using Eclipse 3.1.0 and the J2ME Wireless Toolkit 2.2 etc all configured correctly. I am successfully building my MIDlet and emulating the application on the DefaultColourPhone. In one of my classes I have imported some specific class libraries so that I can perform some XML parsing. These are imported as shown below at the top of the file. import org.kxml.*; import org.kxml.parser.*; import org.kxml.parser.XmlParser; I then go into the Project -> Properties, click on the Libraries tab and have tried including the libraries from an external JAR as well as “Add class folder”. When I added a class f   More>>

To anyone that can help me,



I have developed an application in J2ME using Eclipse 3.1.0 and the J2ME Wireless Toolkit 2.2 etc all configured correctly. I am successfully building my MIDlet and emulating the application on the DefaultColourPhone. In one of my classes I have imported some specific class libraries so that I can perform some XML parsing. These are imported as shown below at the top of the file.



import org.kxml.*;

import org.kxml.parser.*;

import org.kxml.parser.XmlParser;




I then go into the Project -> Properties, click on the Libraries tab and have tried including the libraries from an external JAR as well as “Add class folder”. When I added a class folder I created a new directory in the project directory called “lib” and extracted the ZIP file of the library files into this folder. Then going into Eclipse I add the using the “Add class folder” option. This works as it should. Eclipse build’s the application without any errors or warnings and can see the libraries attached to the package. Even under the build Order and Export properties, the kxml libraries are listed.



Yet for some reason, whilst running the emulator and calling the constructor to XmlParser, the application halts and the following error message is displayed in the console window:







I am lost as to why the build is reporting no errors and Eclipse can see the imported libraries without a problem, but when I run the application I get this message. I have searched high and low without any haven’t found anything explaining why this might be happening.



I also thought that it might help if I posted an image of my project file hierarchy that it might shed some light on this problem.



Eclipse Screenshot



I would greatly appreciate any information anyone can supply.



Regards
GaNkEd.

   <<Less

Re: MIDlet Runtime error Imported libraries not included in package build

Posted By:   david_beaumont  
Posted On:   Tuesday, September 6, 2005 07:39 AM


There seem to be two related things th;at you might wish to consider here (I have just this minute figured out how to get my stuff working in the way you describe).






Firstly, I am using kxml2-min.jar which I downloaded as part of the kxml distribution. All I needed to do was select my destination project, right click, and go to:




Build Path
-> Configure Build Path
-> Libraries
-> Add external JARs


From there, select the JAR file via the browser (I first copied it to a new subdirectory inside the eclipse directory to make sure it didn't suffer if I moved the kxml distribution).



Now go to the "Order and Export" tab (in the same Build Path dialog) and select the JAR if it's not already selected. This allows the JAR to be exported to the MIDlet packaging stage (if the JAR was already installed on the device then you wouldn't need to do this stage).



This completely avoids the need to have kxml as a source based project in eclipse.





Secondly (the bit that caused me issues) was trying to do what you're doing, which is link a 'library' project into a 'MIDlet' project. If the compiler can see the library project but it fails at runtime (as you seem to be describing) then try this:

Right click on the library project and go to:


J2ME
-> Create Package


Now you should have a 'deployed' directory in the library package.

Now right click the MIDlet project and go to:


Build Path
-> Configure Build Path
-> Libraries
-> Add JARs


This should let you browse to the deployed directory in the library project where you can select the library JAR.



Now, as before, you go to the "Order and Export" tab and make sure the JAR is selected.






The only odd thing here is that the "Order and Export" tab now shows two entries for the library project: one because we have included the project as a dependency for compiling (this should not need to be ticked) and one because we included the JAR (this should be ticked).



If anyone can suggest a neater way to do this that uses the library project directly, rather than the deployed JARs, please let me (us) know.

About | Sitemap | Contact