This site requires JavaScript, please enable it in your browser!
Greenfoot back
sci-fair-guy
sci-fair-guy wrote ...

2012/5/5

Libraries Don't make it into applet Jars

sci-fair-guy sci-fair-guy

2012/5/5

#
One can set a path to another blueJ or Greenfoot project to use as a library via Edit/Perferences/Library tab. That's very nice :-). But when I create an applet (Share/Webpage) the jars that are created do not contain the library classes, and so the applet does not run on the webpage (it doesn't produce any error messages either :-(). What is the logic behind this, or am I missing something? We have a few things to share, but really don't want to maintain duplicate code all over the place. (Just found out about the 2.2.0 release and will try that ;-). Thanks for fixing it in 2.2.0 or for replying (which ever "works").
sci-fair-guy sci-fair-guy

2012/5/5

#
Just tried it with 2.2.0 --- drum roll ---- It worked sort of. I think it worked with previous releases too, I've been trying a lot of things and couldn't tell which actually did it ... now I think I really understand. Greenfoot works great with libraries, but if you want to use them in an applet, you have to manually copy the classes into your greenfoot project - top level - folder. I use multiple folders in some projects. It appears (I'll try it next!) that the classes from subfolders need to be copied to the top folder. Seems the applet converter should do that for us. Does Greenfoot use the class file in the top folder when developing with its library reference in Greenfoot? Maybe someone could comment on that.
sci-fair-guy sci-fair-guy

2012/5/5

#
Hi again, (I seem to be having a public conversation with myself) I just converted one of my more complex projects to an applet and successfully ran it. It has multiple folder levels for xml config files and libraries. All the library class files had to be copied to the top level folder. I access the xml files as jar resources, but I'm still not completely sure that is necessary. The projects that open a JOptionPane to get a config file don't appletize - presumably because of "sandbox" limitations. I should be able to provide a list of files to pick from that are in the Jar though. I believe as long I stick to reading and writing to files (resources) in my Jar file, everything should work when converted to an applet. I downloaded the fileiox project, but have only looked at a couple items in there. It may have the answers I want, but it'll take more time than I want to figure it out. Time for lunch!
davmac davmac

2012/5/5

#
I think you answered your own question to a degree? The 'export to applet' functionality of Greenfoot isn't really intended to work with external libraries; more of a design oversight that a deliberate omission however. In regards to file access, you certainly can't do that with an applet, and even to access resources inside the applet you can't use conventional File related classes (File, FileInputStream etc). Once inside the applet the resources aren't files anymore. See this discussion.
You need to login to post a reply.