Exporting Question

Eclipse And Project Management
Now I'm not entirely sure if this question is so specific to Eclipse that I should put it in the Eclipse section or not. What I'm trying to figure out is how I can export a Eclipse Java Project and customize which files they have the source code to or whatnot. For example, I have a project in Eclipse setup with a Package Battlebots and exists such:

Battlebots
Battlebots.AI

Anything in the AI I want them to have access to the source code but in the Battlebots I only want them to have access to the .class files for running purposes. The only things they need to change to run the program should be their AI's which are in that specific section of BattleBots.

I don't need a direct answer here, but its appreciated. Even a good place to start looking at Eclipse prject builds and what not...

Too it is interesting to me!

I normally don't export source in my JAR files, so I'm not sure exactly which set of options will produce the best results, but...

Right click on the project folder and select Export, JAR file.

I believe you should select to export "all output folders" and "Java source files".

In the list section above, deselect anything you don't want included, particularly the source files you want to hide.

When you are done, check the JAR contents to make sure it did what you expected. Note that the .class and .java files may be in the same folders, even though you specify separate destinations in your project. That should not hurt anything.

WinRAR and 7Zip are both good tools for looking in JAR files, as well as ZIP files in general. They are far better than anything Windows XP provides, if that is what you are stuck with.

Is this the best method to allow someone to import your project as well? For example, say I want a friend to try out this Project, but as I said I don't want him to get access to most of the source files. When I test Importing it myself, It apparently doesn't import properly and it won't run like normal. Its possible I could be importing wrong or I could be exporting wrong, even after following your directions.

Let me make a couple of general remarks, and then I will address your issue directly. I think my past efforts to be brief have kept me from being clear.

Java source files are simply a means to hold human-editable content that Java can turn into files that contain Java-usable content. Java doesn't have the concept of a "project".

The project concept was created by IDE designers, as a means of organizing source and other resources in a human-friendly way (people starting out with Eclipse might argue about the "friendly" part).

The form of a "project" is entirely dependent on the IDE, as some people find out the hard way when the try to switch IDE's. Most IDE's follow certain conventions, and some of those conventions are pushed upon the IDE by Java itself.

Getting back to your problem, you want to give your students part of your project, along with the generated Java content (mainly .class files). There are three ways to approach this.

Stuff everything in a JAR file and let the students sort it out. This is what I suggested previously, based on what you were specifically asking. The students would have to create an empty project and copy the source from the JAR file into their projects, along with adding a reference to the JAR file. This is easy on you but more work for your students. On the other hand, that was never an issue when *I* was in college. Note: The students must have a tool, such as WinRAR or 7-Zip, that can open JAR files. Option: Don't export the source at all, and simply zip up the source you want them to have and let them unzip that.

Don't give the students the source; simply give them abstract classes that they must extend. This is a more real-life scenario; you provide them with a framework that requires them to implement some of the behavior. However, it forces you to work harder to make the abstract classes usable.

Give the students the generated content in a JAR file, make a copy of your project, delete source you do not want them to see, and put the remainder of the project in a ZIP file. The students would then unzip the project, import it to their workspace, add a reference to the JAR, and off they go. However, the students must use the same IDE you are using.

Personally, I like option 2 the best, but, for me, creating abstract classes in a framework takes about 10x more effort than just hammering out the code.

Otherwise, I would go with the modified version of 1. If you are truly kind (apparently, I'm not), go with option 3.

I think I'm getting confused with a few key terms. When I hear source I'm thinking of the .java which I believe is correct. I think another thing that could be giving me grief is the fact that I'm using a package. I thought this would be extremely simple to do, but heres the steps I've taken.

This produces a Jar file with ONLY .class files and my resources (such as pictures etc).

So I think Exporting is solved. (Oh btw, I'm not going to give them any source files at all now, makes exporting one step easier).

So now when I pretend that I am a student is when I have the trouble. Heres what I do:

1. Create empty class without using src/bin folders (exported project did not use the src/bin folders, just the root directory for both .java and .class(
2. Import - Archive File - Select my JAR I exported earlier

What happens is Nothing is imported. The only way I can actually get to see these class files at all is to simple add a external Library and select the JAR file and then all of the stuff I exported comes up under an external library. I can even run the program from that library but I would much rather have that content in the project itself.