This site requires JavaScript, please enable it in your browser!
Greenfoot back
jeffret
jeffret wrote ...

2011/12/10

External libraries or classes

jeffret jeffret

2011/12/10

#
Is it possible to use external libraries or classes inside Greenfoot? I looked for a way to modify the classpath that Greenfoot uses, but haven't been able to locate one. I know that I can copy the files .java files into the Greenfoot scenario directory, but I want to manage these utility classes externally, via NetBeans, and just uses the classes inside Greenfoot. I'm teaching my sons and a couple of friends programming using Greenfoot and Netbeans. We've been doing some exploration of Java I/O in Netbeans and now we want to use some of the utilities we've created in Greenfooot. Thanks! Jeff
giordanno92 giordanno92

2011/12/12

#
I'm not sure, but I think this is the same doubt that I was having with Eclipse and ppl from greenfoot (i think) discussed it here. I'm just answering this post cause I want help on that too :D...
AwesomeNameGuy AwesomeNameGuy

2011/12/12

#
I would also be interested in seeing replys to this topic.
nccb nccb

2011/12/12

#
In Greenfoot, if you go to Edit menu, then Preferences, there is a Libraries tab. From there, you can add JARs or directories (with .class files in them) to the Greenfoot classpath for all scenarios. That should allow you to use external Java code from within Greenfoot. Meanwhile, what I think giordanno92 is referring to is using the Greenfoot libraries from Java code developed and run outside Greenfoot, which is not practically feasible, and not something we are likely to support.
AwesomeNameGuy AwesomeNameGuy

2011/12/13

#
Fair enough. Thanks for the tip.
giordanno92 giordanno92

2011/12/14

#
Yeah, looking now I think I've misunderstood the doubt of the topic, cause I've already seen something about BlueJ and NetBeans on the java site (i think), so I thought that was the question... I'm really hoping Greenfoot can reach the IDE level of NetBeans and Eclipse about make coding easier. But I can't help myself about how faster I can code with those IDEs, sorry for any inconvenience.
jeffret jeffret

2011/12/17

#
Thanks nccb! That should work well enough. It's too bad the setting is Greenfoot-wide rather than being a per-project setting. If it were a property of a Greenfoot project (scenario) then we could just bring in the pieces we need for each individual project. This casts the net a bit wider than necessary, but it will still work.
jeffret jeffret

2011/12/17

#
giordanno92 wrote...
I'm not sure, but I think this is the same doubt that I was having with Eclipse <snip> I'm just answering this post cause I want help on that too :D...
giordanno92, the method described in this topic can kind of help you accomplish what you want. We've used Netbeans to create a utility library for managing high scores. (Okay, really it was to learn Java I/O, but it has a use.) It was easier to do in Netbeans and it helped my students to expand their understanding. Then we will link back to these classes, as described in this topic, and use them in Greenfoot scenarios. Structure your code in such a way that you can separate out parts that require Greenfoot and parts that don't. Greenfoot makes some things really easy. In other places, it just doesn't have the sophistication of a full IDE. Use different tools and environments for their different strengths. Besides, it's generally a good idea to structure your code to decrease dependencies. It's generally a good idea to separate UI code from the real logic of your program. The Greenfoot classes are basically UI components. If you have a Monster (class) which is an Actor and the Monster has lots of logic, then you could create a MonsterEntity (or better name). Then the Monster could have a MonsterEntity and pass off to it all of the "heavy lifting". Basically, anything which does not extend a Greenfoot class or call something in a Greenfoot class could be implemented in Eclipse or Netbeans and used in Greenfoot. (Such as Vector.) If you do develop utilities or logic classes in Netbeans or Eclipse, write unit tests to make sure those classes work before you start using them in Greenfoot.
You need to login to post a reply.