Home » Eclipse Projects » Eclipse Platform » Using Eclipse with an existing Java project
Using Eclipse with an existing Java project [message #166222] |
Fri, 05 December 2003 00:46  |
Eclipse User |
|
|
|
Originally posted by: chris.staticmethod.net
Hi all,
At my work I am involved in a rather large java project. We have several
developer working on this project and most of them use either vim or emacs,
but I am interested in trying out Eclipse. Our project is "managed" using
Ant and CVS currently, and is basically split into two source trees and a
test tree, and we have a rather large classpath defined in an environment
variable (well, just CLASSPATH).
Anyway, I haven't had much luck trying to use Eclipse with this project. In
this case, I'm more interested in using Eclipse as a very smart code
editor, and not so much as a project management tool (if that makes any
sense). Can anyone help me figure out how to do this? Basically, I'd like
to get Eclipse to be smart about the classpath used in this project (so it
can do things like find classes, do method completion, etc), be able to
build source files individually, and run the class I'm currently editing
(including our JUnit tests).
Thanks,
Chris
|
|
|
Re: Using Eclipse with an existing Java project [message #166318 is a reply to message #166222] |
Fri, 05 December 2003 09:52   |
Eclipse User |
|
|
|
Originally posted by: eclipse-user.jibeinc.com
Chris TenHarmsel wrote:
> Hi all,
> At my work I am involved in a rather large java project. We have several
> developer working on this project and most of them use either vim or emacs,
> but I am interested in trying out Eclipse. Our project is "managed" using
> Ant and CVS currently, and is basically split into two source trees and a
> test tree, and we have a rather large classpath defined in an environment
> variable (well, just CLASSPATH).
Do you mean that you have to set your _system_ CLASSPATH to include a
bunch of JARs in order to build and run your application? And the whole
team puts up with this? If you're using Ant, why not let it to the work
for you - it is a good practice to not even have a system CLASSPATH,
so that your build env takes care of everything. I've always considered
it a requirement that an entire project can be checked out of SCM and
built/run without any manual setup by the developer, other than perhaps
editing a line or two in a build.properties file.
Anyway, on to your question...
> Anyway, I haven't had much luck trying to use Eclipse with this project. In
> this case, I'm more interested in using Eclipse as a very smart code
> editor, and not so much as a project management tool (if that makes any
> sense). Can anyone help me figure out how to do this? Basically, I'd like
> to get Eclipse to be smart about the classpath used in this project (so it
> can do things like find classes, do method completion, etc), be able to
> build source files individually, and run the class I'm currently editing
> (including our JUnit tests).
If you haven't already done so, use Eclipse's CVS Exploring perspective
to browse your CVS repository and find the module for your project.
Select the root of your project and choose "Check out as..." from the
right-click menu.
Alternatively, you can create a new Eclipse Java Project and uncheck the
"Use defaults" box under Project Contents to point it to an existing
check-out on your system. If you do this, however, it is highly
recommended that you _do not_ mix Eclipse CVS operations with
command-line CVS operations. Eclipse is an awesome CVS client (the best,
by far, that I've used), so try using just it for a while to see how it
works out for you.
Once you've got the project created, you need to edit its Properties,
especially the Java Build Path section. That is where you can define the
build-time classpath that Eclipse uses to find JARs and other code your
project depends on. Go through each tab in the Java Build Path section,
defining source directory(ies), build output folder, perhaps other
Projects if you have some kind of "common" or "library" project with
shared code/components. Then go to the Libraries tab and add any/all
JARs that the Project needs to build (are they part of your CVS checkout
or stored elsewhere on your machine?).
The only other Properties section that I ever really mess with sometimes
is the Java Compiler choice. That lets you specify the compiler options
you want to compile with.
Now with this set up, your project should do a full rebuild
automatically when you close the dialog. If there are any compile
problems or unresolved classes (you missed a library JAR, perhaps?),
they will show up in the Tasks view. As you save code, it will
automatically be incrementally compiled, only what has changed and
whatever depends on it.
I recommend the Java Browsing perspective for working with code. Open it
and browse all your packages. I recommend setting up a Working Set that
includes only your own code, so you dont' have to look at a bunch of
packages/classes from libraries/JARs you're using. Click the down-arrow
on one of the panels (Projects/Packages/Types/etc.) to select/define a
working set.
That should get you going. Let us know what your next issue/question is
when you get to it... ;-)
Oh yeah, and if you haven't done so already, take a romp through the
tutorials that are included in Eclipse's Help - they're usually pretty
helpful in showing you stuff you didn't know was there.
HTH,
Eric
--
Eric Rizzo
Software Architect
Jibe, Inc.
http://www.jibeinc.com
|
|
|
Re: Using Eclipse with an existing Java project [message #166322 is a reply to message #166222] |
Fri, 05 December 2003 09:54   |
Eclipse User |
|
|
|
Originally posted by: jdf.pobox.com
Chris TenHarmsel wrote:
> Basically, I'd like
> to get Eclipse to be smart about the classpath used in this project (so it
> can do things like find classes, do method completion, etc), be able to
> build source files individually, and run the class I'm currently editing
> (including our JUnit tests).
It will take some patience, but there's no reason that you and your
co-workers cannot co-exist with different IDEs.
Check out the existing project as a Java project via Eclipse's team
features.
Right-click on the new project in the Java perspective, choose
"Properties". Click "Java build path".
Choose the "Source" tab. Iteratively add the folders containing source.
Choose the "Libraries" tab. For any library jar files that are within
the project directory, us "Add JARs..."; for any library jar files that
are in other places on your disk, use "Add External JARs...", but
consider moving them into your project.
When you dismiss the dialog, your project should build. If there are
build problems, try and use the steps above to correct them.
When you're done, you will synchronize your project with the CVS
repository. The only changes should be the addition of two files:
..project and .classpath. Nobody on your team should complain about that. :)
--
Jonathan Feinberg jdf@us.ibm.com
http://domino.research.ibm.com/cambridge/research.nsf/pages/ cue.html
|
|
|
Re: Using Eclipse with an existing Java project [message #166324 is a reply to message #166222] |
Fri, 05 December 2003 09:55   |
Eclipse User |
|
|
|
On Fri, 05 Dec 2003 00:46:25 -0500, Chris TenHarmsel wrote:
> Hi all,
> At my work I am involved in a rather large java project. We have several
> developer working on this project and most of them use either vim or emacs,
> but I am interested in trying out Eclipse. Our project is "managed" using
> Ant and CVS currently, and is basically split into two source trees and a
> test tree, and we have a rather large classpath defined in an environment
> variable (well, just CLASSPATH).
>
> Anyway, I haven't had much luck trying to use Eclipse with this project. In
> this case, I'm more interested in using Eclipse as a very smart code
> editor, and not so much as a project management tool (if that makes any
> sense). Can anyone help me figure out how to do this? Basically, I'd like
> to get Eclipse to be smart about the classpath used in this project (so it
> can do things like find classes, do method completion, etc), be able to
> build source files individually, and run the class I'm currently editing
> (including our JUnit tests).
Apart from defining one java project with three source folders
(Properties>Build Path>Source Folders on the project), and adding any
external jars to the build path, what do you miss?
Simon
|
|
|
Re: Using Eclipse with an existing Java project [message #166422 is a reply to message #166318] |
Fri, 05 December 2003 10:12   |
Eclipse User |
|
|
|
Originally posted by: chris.staticmethod.net
Eric Rizzo wrote:
> Chris TenHarmsel wrote:
>
>> Hi all,
>> At my work I am involved in a rather large java project. We have several
>> developer working on this project and most of them use either vim or
>> emacs,
>> but I am interested in trying out Eclipse. Our project is "managed"
>> using Ant and CVS currently, and is basically split into two source trees
>> and a test tree, and we have a rather large classpath defined in an
>> environment variable (well, just CLASSPATH).
>
> Do you mean that you have to set your _system_ CLASSPATH to include a
> bunch of JARs in order to build and run your application? And the whole
> team puts up with this? If you're using Ant, why not let it to the work
> for you - it is a good practice to not even have a system CLASSPATH,
> so that your build env takes care of everything. I've always considered
> it a requirement that an entire project can be checked out of SCM and
> built/run without any manual setup by the developer, other than perhaps
> editing a line or two in a build.properties file.
>
> Anyway, on to your question...
>
>> Anyway, I haven't had much luck trying to use Eclipse with this project.
>> In this case, I'm more interested in using Eclipse as a very smart code
>> editor, and not so much as a project management tool (if that makes any
>> sense). Can anyone help me figure out how to do this? Basically, I'd
>> like to get Eclipse to be smart about the classpath used in this project
>> (so it can do things like find classes, do method completion, etc), be
>> able to build source files individually, and run the class I'm currently
>> editing (including our JUnit tests).
>
> If you haven't already done so, use Eclipse's CVS Exploring perspective
> to browse your CVS repository and find the module for your project.
> Select the root of your project and choose "Check out as..." from the
> right-click menu.
> Alternatively, you can create a new Eclipse Java Project and uncheck the
> "Use defaults" box under Project Contents to point it to an existing
> check-out on your system. If you do this, however, it is highly
> recommended that you _do not_ mix Eclipse CVS operations with
> command-line CVS operations. Eclipse is an awesome CVS client (the best,
> by far, that I've used), so try using just it for a while to see how it
> works out for you.
>
> Once you've got the project created, you need to edit its Properties,
> especially the Java Build Path section. That is where you can define the
> build-time classpath that Eclipse uses to find JARs and other code your
> project depends on. Go through each tab in the Java Build Path section,
> defining source directory(ies), build output folder, perhaps other
> Projects if you have some kind of "common" or "library" project with
> shared code/components. Then go to the Libraries tab and add any/all
> JARs that the Project needs to build (are they part of your CVS checkout
> or stored elsewhere on your machine?).
> The only other Properties section that I ever really mess with sometimes
> is the Java Compiler choice. That lets you specify the compiler options
> you want to compile with.
>
> Now with this set up, your project should do a full rebuild
> automatically when you close the dialog. If there are any compile
> problems or unresolved classes (you missed a library JAR, perhaps?),
> they will show up in the Tasks view. As you save code, it will
> automatically be incrementally compiled, only what has changed and
> whatever depends on it.
> I recommend the Java Browsing perspective for working with code. Open it
> and browse all your packages. I recommend setting up a Working Set that
> includes only your own code, so you dont' have to look at a bunch of
> packages/classes from libraries/JARs you're using. Click the down-arrow
> on one of the panels (Projects/Packages/Types/etc.) to select/define a
> working set.
>
> That should get you going. Let us know what your next issue/question is
> when you get to it... ;-)
> Oh yeah, and if you haven't done so already, take a romp through the
> tutorials that are included in Eclipse's Help - they're usually pretty
> helpful in showing you stuff you didn't know was there.
>
> HTH,
> Eric
Thanks, this info was very helpful. I've finally got the project all set
up. One reason that we (I previously used emacs) set up the classpath in
the environment is that we very often compile and run just a single java
class that we're working on, for example tests. It's common to work on the
code and test at the same time, and then just run the test class by itself
to check our progress on the class (since we use the XP methodology we test
first and use it to drive our development).
I've had luck running a single test class, so I'm happy that works.
Thanks again for all the help!
-Chris
|
|
| |
Re: Using Eclipse with an existing Java project [message #166469 is a reply to message #166318] |
Fri, 05 December 2003 11:08   |
Eclipse User |
|
|
|
Originally posted by: kai.emptydomain.de
Eric Rizzo wrote:
> Eclipse is an awesome CVS client (the best,
> by far, that I've used), so try using just it for a while to see how it
> works out for you.
I beg to differ. The Eclipse CVS client is quite good -- I've been using
it for some months now without running away from it screaming ;-)
However, it is not "by far" the best client that I've used.
I started to write about a list of differences between the two, but after
thinking about it, it turns out that they are mostly equivalent. PCL-CVS
has better keyboard navigation (you can do EVERYTHING from the keyboard)
and ChangeLog support (it can pre-populate ChangeLog entries with filename
and method name). And Eclipse has context menus and looks better.
But I have much more experience using PCL-CVS than Eclipse, so perhaps
somebody who also knows both could correct me if I am missing something.
(I thought that the Eclipse compare view is better than Emacs, but Emacs
has ediff which does the same, only without those curvy lines. Is the
resource history view in Eclipse searchable? I wish I could search the
commit messages for a certain regexp.)
Kai
|
|
|
Re: Using Eclipse with an existing Java project [message #166493 is a reply to message #166469] |
Fri, 05 December 2003 11:50   |
Eclipse User |
|
|
|
Originally posted by: chris.staticmethod.net
Kai Großjohann wrote:
> Eric Rizzo wrote:
>
>> Eclipse is an awesome CVS client (the best,
>> by far, that I've used), so try using just it for a while to see how it
>> works out for you.
>
> I beg to differ. The Eclipse CVS client is quite good -- I've been using
> it for some months now without running away from it screaming ;-)
> However, it is not "by far" the best client that I've used.
>
> I started to write about a list of differences between the two, but after
> thinking about it, it turns out that they are mostly equivalent. PCL-CVS
> has better keyboard navigation (you can do EVERYTHING from the keyboard)
> and ChangeLog support (it can pre-populate ChangeLog entries with filename
> and method name). And Eclipse has context menus and looks better.
>
> But I have much more experience using PCL-CVS than Eclipse, so perhaps
> somebody who also knows both could correct me if I am missing something.
>
> (I thought that the Eclipse compare view is better than Emacs, but Emacs
> has ediff which does the same, only without those curvy lines. Is the
> resource history view in Eclipse searchable? I wish I could search the
> commit messages for a certain regexp.)
>
> Kai
I'd have to agree here, I couldn't get Eclipse to talk to my CVS server, it
kept giving me errors even though I seemed to have everything set up
correctly, and it's error message didn't offer much help. So I'm probably
going to stick to Cervisia or the command line.
I'm still having troubles running individual classes as well, if I choose to
run a class as a java application, it gives me a ClassDefNotFoundException
in my main function, or complains that the class I'm trying to run is in th
project build path (or something similar to that).
Chris
|
|
| | |
Re: Using Eclipse with an existing Java project [message #167162 is a reply to message #167112] |
Mon, 08 December 2003 08:48   |
Eclipse User |
|
|
|
Originally posted by: chris.staticmethod.net
Kai Großjohann wrote:
> Chris TenHarmsel wrote:
>
>> I'd have to agree here, I couldn't get Eclipse to talk to my CVS server
>
> Well, saying that Eclipse's CVS support is bad because you couldn't get it
> to talk to your CVS server would be unfair, I think. Especially when
> compared with Emacs. Setup problems are a problem, but to be fair you'd
> encounter your own share of setup problems with Emacs, I'm sure...
>
> I'm not sure where the problems come from that you're seeing. Did you try
> to connect to the CVS server from the command line and did that work?
>
> Kai
Yes, I work with CVS every day, and had previously checked out the
repository before I started working on it with Eclipse. Eclipse
(3.0something, the newest available on the website) even told me this was a
previously checked out CVS directory and read my settings from the CVS dir
in the project's root. I haven't gotten it to work yet, but I'm not
blaming that on Eclipse, I just probably haven't found some setting that I
need to specify.
|
|
|
Re: Using Eclipse with an existing Java project [message #167170 is a reply to message #167138] |
Mon, 08 December 2003 08:51   |
Eclipse User |
|
|
|
Originally posted by: chris.staticmethod.net
Horváth, Csaba wrote:
> Hi,
>
> What version of Eclipse and CVS do you use? Eclipse 2.1.x (and older ones)
> has known problems with CVS 1.11.7 and later versions. See
> http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout
7E/platform-vcm-home/do
> cs/online/cvs_features2.0/cvs-faq.html#server_1a (url may wrap) for
> details.
>
> For the NoClassDefFoundError (I think you mean this): did you compile your
> classes outside of Eclipse (from command line or Ant)? If yes, make sure
> to do the following:
> - the output folder of your compilation process is set up for your Eclipse
> project as the output folder (you can set it in 'Project
> properties'->'Java build path'->'Source'->'Default output folder'); if it
> is not in the project you can use a linked folder to specify the location
> - perform a 'Refresh' for that folder after every compilation (if you run
> an external compilation process or Ant task from Eclipse you can do it
> automatically: see the 'Refresh' tab in the external tools configuration)
>
> HTH,
> Regards,
> Csaba
Is there a way to have it build in place instead of in a single, external
path? I have two source dirs, so I can't just symlink the output directory
to the source directory in this case.
Thanks,
Chris
>
> "Chris TenHarmsel" <chris@staticmethod.net> wrote in message
> news:bqqcup$ee5$3@eclipse.org...
>> Kai Großjohann wrote:
>>
>> > Eric Rizzo wrote:
>> >
>> >> Eclipse is an awesome CVS client (the best,
>> >> by far, that I've used), so try using just it for a while to see how
>> >> it works out for you.
>> >
>> > I beg to differ. The Eclipse CVS client is quite good -- I've been
> using
>> > it for some months now without running away from it screaming ;-)
>> > However, it is not "by far" the best client that I've used.
>> >
>> > I started to write about a list of differences between the two, but
> after
>> > thinking about it, it turns out that they are mostly equivalent.
> PCL-CVS
>> > has better keyboard navigation (you can do EVERYTHING from the
>> > keyboard) and ChangeLog support (it can pre-populate ChangeLog entries
>> > with
> filename
>> > and method name). And Eclipse has context menus and looks better.
>> >
>> > But I have much more experience using PCL-CVS than Eclipse, so perhaps
>> > somebody who also knows both could correct me if I am missing
>> > something.
>> >
>> > (I thought that the Eclipse compare view is better than Emacs, but
>> > Emacs
>> > has ediff which does the same, only without those curvy lines. Is the
>> > resource history view in Eclipse searchable? I wish I could search the
>> > commit messages for a certain regexp.)
>> >
>> > Kai
>>
>> I'd have to agree here, I couldn't get Eclipse to talk to my CVS server,
> it
>> kept giving me errors even though I seemed to have everything set up
>> correctly, and it's error message didn't offer much help. So I'm
>> probably going to stick to Cervisia or the command line.
>>
>> I'm still having troubles running individual classes as well, if I choose
> to
>> run a class as a java application, it gives me a
>> ClassDefNotFoundException in my main function, or complains that the
>> class I'm trying to run is in
> th
>> project build path (or something similar to that).
>>
>> Chris
>>
|
|
| |
Re: Using Eclipse with an existing Java project [message #167201 is a reply to message #166454] |
Mon, 08 December 2003 09:46   |
Eclipse User |
|
|
|
Originally posted by: eclipse-user.jibeinc.com
Chris TenHarmsel wrote:
> I've gotten to my first issue. :) I have a class that extends JPanel, and
> I've written a main() inside the class so that I can run it to see what it
> looks like. If I execute this class from the commandline, it pops up the
> frame perfectly fine, but choosing Run->Run As->Java Application gives me a
> NoClassDefFound exception for the class that the main is inside of. Any
> ideas about how to fix this?
The class you're trying to run, it is included in your Eclipse Project,
right? I mean, it is being compiled by Eclipse from your source
directory. Make sure it is included in the Project's source directories.
Also check the launch configuration that you're using to run the class -
make sure it includes that class' Eclipse Project on its run path.
Are there any problems reported in the Tasks view that would be stopping
the Eclipse Project from building completely?
This has happened to me occasionally, but it is always related to some
build problem or my launch config not including the right Project/library.
HTH,
Eric
--
Eric Rizzo
Software Architect
Jibe, Inc.
http://www.jibeinc.com
|
|
|
Re: Using Eclipse with an existing Java project [message #167256 is a reply to message #167201] |
Mon, 08 December 2003 10:20   |
Eclipse User |
|
|
|
Originally posted by: chris.staticmethod.net
Eric Rizzo wrote:
> Chris TenHarmsel wrote:
>> I've gotten to my first issue. :) I have a class that extends JPanel,
>> and I've written a main() inside the class so that I can run it to see
>> what it looks like. If I execute this class from the commandline, it pops
>> up the frame perfectly fine, but choosing Run->Run As->Java Application
>> gives me a
>> NoClassDefFound exception for the class that the main is inside of. Any
>> ideas about how to fix this?
>
> The class you're trying to run, it is included in your Eclipse Project,
> right? I mean, it is being compiled by Eclipse from your source
> directory. Make sure it is included in the Project's source directories.
> Also check the launch configuration that you're using to run the class -
> make sure it includes that class' Eclipse Project on its run path.
> Are there any problems reported in the Tasks view that would be stopping
> the Eclipse Project from building completely?
> This has happened to me occasionally, but it is always related to some
> build problem or my launch config not including the right Project/library.
How do you make sure that the launch configuration that you're using to run
the class includes that class' Eclipse Project on it's run path? The class
is part of the project, so I would suspect that this is the problem, but
I'm having a hard time locating where I would set this. Is it in the
project settings?
Thanks for the help,
Chris
|
|
| | | |
Re: Using Eclipse with an existing Java project [message #167593 is a reply to message #167162] |
Mon, 08 December 2003 16:25  |
Eclipse User |
|
|
|
Originally posted by: kai.emptydomain.de
Chris TenHarmsel <chris@staticmethod.net> writes:
> Yes, I work with CVS every day, and had previously checked out the
> repository before I started working on it with Eclipse.
I see. Well, I did a new checkout into the Eclipse project
directory. Worked like this:
- Create new (empty) Eclipse project foo (ends up in
y:/workspace/foo).
- Use CVS repository browser to find my directory, foo-web.
- Use the context menu and then "Check out as" (I think that's what it
was called). I chose "as subdir in an existing project".
- This produced a directory y:/workspace/foo/foo-web.
Now I can put the stuff that should go into the repository into
y:/workspace/foo/foo-web, and all the stuff that Eclipse creates for
itself is not in CVS.
Maybe you could try to use the CVS repository browser first. That
ought to tell you whether you're having ssh connection problems, or
whether something else is wrong.
Kai
|
|
|
Goto Forum:
Current Time: Tue Sep 16 18:40:43 EDT 2025
Powered by FUDForum. Page generated in 0.06990 seconds
|