Results 1 to 10 of 10
  1. #1
    Moncleared is offline Member
    Join Date
    Jan 2009
    Posts
    92
    Rep Power
    0

    Default 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...

    Thanks

  2. #2
    Moncleared is offline Member
    Join Date
    Jan 2009
    Posts
    92
    Rep Power
    0

    Default

    I need to make it so when someone else imports this JAR they'll get the package but the Battlebots will only have class files for running and the Battlebots.AI will have source files.

    Currently I'm doing the following:

    Export ---> Jar File ---> I check mark Generated Class and Source ---> next ---> next ---> then I use the Sealed package to seal them but it doesn't do it =/

  3. #3
    Moncleared is offline Member
    Join Date
    Jan 2009
    Posts
    92
    Rep Power
    0

    Default

    Anyone know of another Eclipse community forum that I could get some feedback from? Thanks

  4. #4
    rittachkas is offline Member
    Join Date
    Jan 2009
    Location
    Posts
    1
    Rep Power
    0

    Default Too it is interesting to me!

    Too it is interesting to me! A good question, the truth not all has understood.

  5. #5
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    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.

  6. #6
    Moncleared is offline Member
    Join Date
    Jan 2009
    Posts
    92
    Rep Power
    0

    Default

    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.

  7. #7
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    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.
    1. 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.
    2. 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.
    3. 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.

  8. #8
    Moncleared is offline Member
    Join Date
    Jan 2009
    Posts
    92
    Rep Power
    0

    Default

    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.

    1. Right click Project, Export.
    2. Select Jar File
    3. File Specification - Export all output folders for checked projects

    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.

    Thanks for all your help so far, you've been great!

  9. #9
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    What you are seeing is exactly what I would expect if you followed option 2.

    You must reference the JAR for the project to use it, as you discovered. If you use the package view, you will see the JAR as part of the project. You can expand the JAR to see its contents.

    In any new Java source, Eclipse will find the public classes and methods in the JAR if you press ctrl-spacebar. You can also extend any of the classes in the JAR.

    Since you have a copy of the JAR, your students need only to export their classes and return them to you.

  10. #10
    Sylar's Avatar
    Sylar is offline Member
    Join Date
    Mar 2009
    Location
    Odessa, Texas
    Posts
    16
    Rep Power
    0

    Default

    My way of importing in eclipse:

    copy -> paste

    directory to interface....(package explorer)

Similar Threads

  1. Issues deploying and exporting
    By uncommon in forum Eclipse
    Replies: 1
    Last Post: 02-18-2009, 06:33 PM
  2. Greenfoot exporting in .jar?
    By sciguy77 in forum New To Java
    Replies: 0
    Last Post: 01-18-2009, 07:06 PM
  3. Exporting my project
    By Nim in forum CLDC and MIDP
    Replies: 3
    Last Post: 11-04-2008, 11:53 AM
  4. Exporting UML diagrams to MS Visio
    By lettyh in forum NetBeans
    Replies: 0
    Last Post: 10-30-2008, 06:19 PM
  5. Exporting from the command line
    By o1121 in forum Eclipse
    Replies: 1
    Last Post: 08-09-2007, 07:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •