aspose file tools*
The moose likes Beginning Java and the fly likes Setting up a Java project in eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Setting up a Java project in eclipse" Watch "Setting up a Java project in eclipse" New topic
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: 38405
    
  23
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: 38405
    
  23
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Setting up a Java project in eclipse