How do I manage a big Java project?
September 18, 2007 8:54 PM   Subscribe

How do I manage the source code for a big Java program?

Back in the olden days, I did a lot of programming in Fortran, Pascal and such. More recently I've developed a good general understanding of OOP and now I'm learning Java. I want to write a pretty big program in Java. It'll probably have 100-200 classes.

What development tool(s) should I use? I'm aware that there are things called "CVS", "Eclipse", and "Ant", although I don't have a good understanding of what they are.

I would strongly prefer to work in OS X, but Windows is also an option.
posted by neuron to Computers & Internet (13 answers total) 4 users marked this as a favorite
 
CVS is a source version control program... But it's kinda crufty around the edges. More modern is Subversion, aka SVN. It's kind of like a giant clearinghouse of diffs of your programs so that you can "roll back" to a previous version of a file if you bork your copy. You can also 'branch' if you have a feature you want to add but it's not ready for mainstream production.

Eclipse is an IDE, or Integrated Development Environment. Think Visual Studio.

Ant is like Make, but for Java.

Of course you can work in OSX. Java's cross-platform... write once, debug everywhere!
posted by SpecialK at 9:06 PM on September 18, 2007


Subversion, the better CVS.
posted by orthogonality at 9:10 PM on September 18, 2007


Eclipse + Subversion for sure.

Ant is useful, but depending on the type of project you are writing it may not be necessary. Eclipse and Ant work well together.

Can you offer more info about the app? Is it database backed? Web app?
posted by AaRdVarK at 9:11 PM on September 18, 2007


I find OS X's "Xcode" IDE to be slightly less maddeningly awful than Eclipse. Of course there's no real need for an IDE at all; use your favorite text editor (TextWrangler, emacs, SubEthaEdit, vi, etc.) and run ant (or make) from a termnal window. Works fine. I usually end up in Xcode eventually, though, cursing it.
posted by hattifattener at 10:27 PM on September 18, 2007


100-200 classes in Java isn't really all that big. For a first project, though, it's big. Likely way too big, but we all start off with vastly overambitious projects, I guess.

So, moving on, OSX is fine. It's Java. Java doesn't much care where it's run.

Eclipse is great. Use it.

CVS or Subversion aren't all that important given that your project is just barely entering the planning phase.

And, while I'm a huge fan of Ant, I wouldn't bother with it just yet either. For now running your project via Eclipse will probably be fine, and having Eclipse just export the project to a jar and a shell script to run your project will take you surprisingly far. When you reach the point where Eclipse's compilation and build tools are too limited, you'll know it. Then take the time to learn to make ant build files.

I'd say just start small and deal with things like code repositories or build systems when the project requires it. The standard Java API is massive, and combined with resources like Apache's Jakarta project, there is an unbelievable wealth of great libraries to build on. If new Java programmers neglect anything, I think it's that they aren't familiar enough with the APIs available and reinvent things that they could get for free.
posted by mragreeable at 10:29 PM on September 18, 2007


SUBVERSION + ECLIPSE = Awsome.

I have a project right now I'm working on. 6797 lines of code, 375 subversions revisions, and I was going to say 100-200 classes was a hell of a lot but it looks like I've got 117 so far. That includes inner classes (even anonymous ones). 91 Java files.

Works like a charm. One annoying thing though is that eclipse was designed with CVS in mind, so you don't have direct access to some of the cooler SVN features, such as the ability to move folders and files while keeping history. HOWEVER, if you do move a file in eclipse, using the refactoring tools, then commit, it still keeps your history. So it's more a minor annoyance then then a mediums sized annoyance.

And it makes syncing between computers practically transparent. I can work on my project from any machine with eclipse installed.
posted by delmoi at 10:29 PM on September 18, 2007


The standard Java API is massive, and combined with resources like Apache's Jakarta project, there is an unbelievable wealth of great libraries to build on.

I had never thought to check the jakarta project for class libraries. It looks like this project might help solve a problem I've been having, which is figuring where a URL redirects too. The built in java URL class will download the data, but it won't tell you if it redirected.
posted by delmoi at 10:34 PM on September 18, 2007


CVS or Subversion aren't all that important given that your project is just barely entering the planning phase.

Take this with a grain of salt. If you've ever lost even a couple hours worth of work (power outage, editor crash, accidental deletion or overwrite), you know how painful that feels. Spend a week getting something to build and run, and you won't want to repeat the process if your files vanish. Source repositories (like cvs & subversion) act as a buffer against such stupidity. I don't do any non-trivial software development (i.e. more than a hundred lines) without sticking things into a controlled repository.

Read up on subversion, learn how to use it, and it will be your friend. Also, make backups of your repository.
posted by knave at 10:34 PM on September 18, 2007


I don't even write shell scripts anymore without checking them into my svn repository of my home directory. :-P
posted by SpecialK at 5:06 AM on September 19, 2007


Of course there's no real need for an IDE at all;

With a strongly typed language like Java, I find the code completion and inline error checking of an IDE to be invaluable. And probably doubles my productivity. YMMV, I suppose.

(Scripting languages or Ruby, not so much.)
posted by smackfu at 5:44 AM on September 19, 2007


There's also Git, the better SVN. But yeah, use some sort of source control or learn how to tie a noose. AND, have that Git/SVN instance running on a server that gets backed up and is redundant. Eclipse is also very powerful if you like IDE's.
posted by Mach5 at 6:00 AM on September 19, 2007


With a project that large, you should also be using automated documentation tools that parse the comments in your source files and build HTML files comprising the API documentation. I don’t do much Java development myself, but I think JavaDoc is the de facto standard.
posted by breaks the guidelines? at 6:26 AM on September 19, 2007


I'd recommend eclipse for a first time java coder, simply because of the inline javadoc. I can often guess at the built in library I'm looking for, and use it's auto-complete and javadoc to figure the exact class/method I mean to call. That saves a bunch of time over firing up the browser and heading over to java.sun.com.

As far as ant, if you are using eclipse, don't worry about it initially. It basically will automate the build process across many complex steps. So you can say "copy files here, edit this file with this value, run the compiler, make a jar file out of it all, then add it to subversion with the specified tag". You don't need that yet, although you will at some point.

Something else you should look into is JUnit. It's a unit testing framework, and getting good with it early in your coding career will be very valuable. It just helps write good code, and even if you make light use of it, understanding WHAT to test for will make you less likely to even write that kind of bug in the first place. I like the Pragmatic Unit Testing book for a quick rundown of what and how to test.
posted by cschneid at 6:55 AM on September 19, 2007


« Older How do you set this watch?   |   Wanted: headphone adapters that don't resemble... Newer »
This thread is closed to new comments.