Basic eclipse questions
So I have spent the past week reading a java programming book, and feel ready to go! But I have a few questions about eclipse first. (I keep reading tutorials and can't quite get things to work as I think they should.) The answers to these might be obvious (just not to me), so thanks in advance for your help!
I understand how to create a new project, and to create a new package and classes within it. If I were starting from scratch, I'd be in good shape. I also understand that theoretically you should be able to import existing source code into your project. But I just can't get this to work out right for me.
I have a template that I am working from. It's all in a folder called "Template2", and contains a bunch of files (including a build.xml file, which I think is for ant) and a bunch of folders including bin, classes, dat, saves, src (and others that I believe are irrelevant). The src folder contains a folder called "Template2", which contains the .java files (four of them). I assume that this is all set up for a project named "Template2" with package name "Template2" (though it wasn't set up to be run with Eclipse).
Approach 1: Create a new project named "basicUntreated" (what I want my project to be called). I set it up to create separate files for source code (src) and output (bin). [Side question: does output going in the bin folder mean .class files or something else??] On the "Libraries" tab (while setting up the new project), I select "Add Library", "User Library", and then two libraries which I have created (filled with jar files) for which I have checked the "System Library (added to the boot class path)" box for. {Side question: I have no idea what "System Library (added to the boot class path)" means. Is this the right thing to have done? One set of libraries is for the agent based modeling stuff (repast libraries) and the other is a set of random things imported in the template. I will be using ant.] Next I click File/Import/File System and browse to select the Template2 folder as the directory from which I want to import. I think I'm doing something wrong from here, because I can't seem to import the source files without screwing up what I think are the package name and project name (new folders are created within my project with the package name "Template2", not "BasicUntreated"). I can't seem to change this to "BasicUntreated", what I want. I'm not even sure that importing files this way is what I want to do. Are things linked appropriately just because the directory structure is right (that is, just because I have a folder named "basicUntreated" inside of my src file, does that necessarily mean that my package is named "basicUntreated")?
Approach 2: I could create a new project as described in approach 1. Then create a new package, named "basicUntreated", and then create a new class, named "Model" (the .java file with main in it). Then very carefully copy all of the parts of Model.java from Template2 into my Model.java file. I tried to do this, preserving what eclipse put into Model.java by default for me (the public static main stuff and class Model stuff). But I'm afraid I've gotten some things wrong... the Model.java file in Template2 is pretty big and slightly convoluted. [Side question: Can I just copy Model.java in its entirety from the Template2 version and paste it over everything that eclipse put into my Model.java by default?] I'd have to then add three more classes and copy/paste the remaining .java files. There has to be an easier way (along the lines of Approach 1).
Any answers to the "side questions" and insight on how to most efficiently (and cleanly) create a new project named "basicUntreated", with pachage name "basicUntreated", and all of the .java files from the other project called Template2 would be so hugely appreciated. I know I'm making this way to difficult. That's easy to do when you are sitting at the bottom of the learning curve! ( I *can* do this!) Thank you, thank you, thank you.
I understand how to create a new project, and to create a new package and classes within it. If I were starting from scratch, I'd be in good shape. I also understand that theoretically you should be able to import existing source code into your project. But I just can't get this to work out right for me.
I have a template that I am working from. It's all in a folder called "Template2", and contains a bunch of files (including a build.xml file, which I think is for ant) and a bunch of folders including bin, classes, dat, saves, src (and others that I believe are irrelevant). The src folder contains a folder called "Template2", which contains the .java files (four of them). I assume that this is all set up for a project named "Template2" with package name "Template2" (though it wasn't set up to be run with Eclipse).
Approach 1: Create a new project named "basicUntreated" (what I want my project to be called). I set it up to create separate files for source code (src) and output (bin). [Side question: does output going in the bin folder mean .class files or something else??] On the "Libraries" tab (while setting up the new project), I select "Add Library", "User Library", and then two libraries which I have created (filled with jar files) for which I have checked the "System Library (added to the boot class path)" box for. {Side question: I have no idea what "System Library (added to the boot class path)" means. Is this the right thing to have done? One set of libraries is for the agent based modeling stuff (repast libraries) and the other is a set of random things imported in the template. I will be using ant.] Next I click File/Import/File System and browse to select the Template2 folder as the directory from which I want to import. I think I'm doing something wrong from here, because I can't seem to import the source files without screwing up what I think are the package name and project name (new folders are created within my project with the package name "Template2", not "BasicUntreated"). I can't seem to change this to "BasicUntreated", what I want. I'm not even sure that importing files this way is what I want to do. Are things linked appropriately just because the directory structure is right (that is, just because I have a folder named "basicUntreated" inside of my src file, does that necessarily mean that my package is named "basicUntreated")?
Approach 2: I could create a new project as described in approach 1. Then create a new package, named "basicUntreated", and then create a new class, named "Model" (the .java file with main in it). Then very carefully copy all of the parts of Model.java from Template2 into my Model.java file. I tried to do this, preserving what eclipse put into Model.java by default for me (the public static main stuff and class Model stuff). But I'm afraid I've gotten some things wrong... the Model.java file in Template2 is pretty big and slightly convoluted. [Side question: Can I just copy Model.java in its entirety from the Template2 version and paste it over everything that eclipse put into my Model.java by default?] I'd have to then add three more classes and copy/paste the remaining .java files. There has to be an easier way (along the lines of Approach 1).
Any answers to the "side questions" and insight on how to most efficiently (and cleanly) create a new project named "basicUntreated", with pachage name "basicUntreated", and all of the .java files from the other project called Template2 would be so hugely appreciated. I know I'm making this way to difficult. That's easy to do when you are sitting at the bottom of the learning curve! ( I *can* do this!) Thank you, thank you, thank you.
