BUG Community

Welcome! Log In

Forums BUG SDK import problem

Subscribe to import problem  10 posts, 4 voices

Log in to reply to this topic
 
Jan 31, 2008 11:20am
Img_missing_medium MarcC 10 posts

First of all I’m sorry if this question seems a little dumb. I’m very new with Java (it is also my first programming language) and up till now all my coding was with J2SE. I am working on a piece of software for the bug where I was going to recycle code from some of my other projects. The problem is that my prior class used the following:
’:evil:’

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

I use the parser obviously for xml files that I load from online and load into an object. Is there a way for me to still have access to these classes or another similar set available. Any information which might point me in the right direction would be greatly appreciated. I really could write this without the parser but it would make my life a lot more complicated, I’d really like not to have to change all my code if not needed.

Thanks

Jan 31, 2008 12:52pm
Medium Bug Labs team kschultz 107 posts

Don't worry I had the same issue, there are so many different versions of Java and they all have a different set of libraries so going between the various versions can be a pain if you are using the built in libraries a lot.

The BUG has PhoneME advanced libraries and they don't have a lot of the javax.* libraries that J2SE has. For XML parsing check out the com.buglabs.util.XmlParser, it is located in the com.buglabs.common jar under Bug Libraries, it is a highly-simplified XML DOM parser that does not support namespaces, but it might be able to do what you need. It would require rewriting a bit of your code but it would be more lightweight than bringing extra jars into your project for xml parsing.

I'm actually writing an app that requires XML parsing right now so I will be using the class, if you want some examples I can post code later today.

Thanks,
Jan 31, 2008 1:03pm
Img_missing_medium MarcC 10 posts

I’ll take a look and see what I can do, hopefully I can get something to work. If you have examples I would appreciate a look at them.

Thanks

Jan 31, 2008 2:11pm
Medium Bug Labs team kschultz 107 posts

Marc,

Angel told me that he used those classes in his app FlickrUppr, if you look he just included a jar that has all of them, so that is the fastest way for you to do it. I’ll post examples when I have them but it doesn’t look like I will have it worked out today.

Thanks,

Jan 31, 2008 2:17pm
Img_missing_medium MarcC 10 posts

No rush, trust me I don’t work that fast….

’:?’

Jan 31, 2008 2:31pm
Img_missing_medium aroman 21 posts

Hi MarcC,

You can make these packages available to your application by using the xerces xml parser. FlickrUppr—from BUGnet—uses xerces to parse the response from flickr.

The key points are:
The xerces.jar must be included in your application. Check jars/xerces.jar within the FlickrUppr project.
xerces.jar should be added to your OSGi Bundle Classpath:
—Look at META-INF/MANIFEST.MF in the Flickr Project. You will see a line like this:

Bundle-ClassPath: .,jars/flickrapi-1.0b4.jar,jars/xerces.jar

This line tells the OSGi framework to make the packages within the bundle, the flickrapi-1.0b4.jar, and xerces.jar available to your bundle. These paths are relative to the bundle.

Please keep in mind that it might be worth making xerces.jar into a separate bundle which exports the desired packages to avoid multiple applications from bundling the same jars.

Let me know if you have any questions.

Regards,
Angel

Jan 31, 2008 3:57pm
Img_missing_medium MarcC 10 posts

Either I’m having a huge brain fart or I just don’t know what I’m doing, both of which are very possible. I went to look at aroman’s FlickrUppr and when I went to download the app I had it open with Eclipse and eclipse opened and went to my current project, nowhere do I see the download. So figuring I was being slow I checked the wiki which says:

To download an application from BUGnet to the Dragonfly SDK:

1. In Eclipse, in the BUGnet panel, click on an application’s link.
2. If necessary, log in with your BUGnet username and password.
3. On the application’s view, click Download Latest Version to SDK.
4. Eclipse downloads and installs the application.

Only thing is that the link just says Dowload lates version but everything else is right. Still nothing. If I download with Eclipse open I get workspace in use, cannot create chose another workspace and if I close eclipse it just opens my current project.

What am I doing wrong….

Jan 31, 2008 4:34pm
Medium Bug Labs team kschultz 107 posts

Marc,

Try using right click to "Import to SDK" rather than left clicking and opening the page. It sounds like Eclipse started to download it but for some reason didn’t finish, the workspace error usually pops up when you try to create a project with the same name as one that is already there. I left you a message on how to contact me directly so we can look at it in real time.

Thanks,

Jan 31, 2008 5:04pm
Medium Bug Labs team finsprings 268 posts

Xerces is pretty hard core and will do namespaces and everything else you could ever need. However, if you only have simple needs then, as Kevin mentions above, I’d recommend trying the XML parser that comes in the BUG libraries. It’s at com.buglabs.util.XmlParser.

I use it in the BUGerServlet class of my BUGer app if you want to see it in action.

Jan 31, 2008 8:08pm
Img_missing_medium MarcC 10 posts

Thanks to all, including @sethk on irc for helping me with my issues including eclipse ones. I am up and running with xerces for now but am looking at the parser included (com.buglabs.util.XmlParser) since it will most likely do what I need it to. Also thanks to Angel for his advice and Kevin for pointing me in the right direction.

Log in to reply to this topic
Forums BUG SDK import problem

Powered by Community Engine

Top
Login
Close
Bottom