| Author |
Setting up a Java project in eclipse
|
Randy Volkart
Greenhorn
Joined: Apr 23, 2007
Posts: 2
|
|
I've got a simple assignment to do, the programming itself should be easy enough to do but I'm having trouble getting it started, as my java's really rusty. Basically all I need to do is add some additional functionality to a class. These are the files I have: ClassFoo.java ClassFooTest.java (references classes in the .jar file) junit.jar build.xml .project .classpath (there is no main class?) I gave it a quick try in netbeans first, but was having a problem with the .jar file, as it doesn't specify a main class. I want to use the .project file to set it up in eclipse, but there doesn't seem to be a direct way to load the project, like in say Visual Studios. The "Project/Open Project" option from the file menu is greyed out, and the "File/Open File" only opens a file in text view. It seemed I was almost able to get it by creating a new java project in an existing folder, but that doesn't seem to import things correctly so I still can't compile it. So any help or suggestions would be appreciated. I've checked out various tutorials, but they focus on starting a project from scratch.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32694
|
|
Welcome to the Ranch. There is a forum devoted to IDEs like Eclipse, but I am surprised you are having difficulty. It is easier on Eclipse than NetBeans. Eclipse->File->New->New Project->ordinary Java project Give your project a name. When it opens, r-click project icon->new->package->create a package. R-click package icon->new->class->ordinary Java class->ClassFooTest On the new class window you can specify its superclass, whether you give it a main method, etc. I usually include "constructor from superclass" myself. Repeat to create FooClass. R-click the project icon->properties->Java build path->add JARs (or add external JARs->explore until you find the junit jar, then add it to the project->Finish. You can get away without using the xml or project or classpath files at all. CR
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32694
|
|
I forgot to say (sorry), you can now copy and paste the entire text of your classes onto the Eclipse window.
|
 |
Randy Volkart
Greenhorn
Joined: Apr 23, 2007
Posts: 2
|
|
Thanks, I was missing this part:
R-click the project icon->properties->Java build path->add JARs (or add external JARs->explore until you find the junit jar, then add it to the project->Finish.
Before I was just directly importing it from File/Import. And you're right, easy enough to do in hindsight, but coming from someone used to Visual Studios going this round-a-bout way is kind of a pain.
|
 |
 |
|
|
subject: Setting up a Java project in eclipse
|
|
|