[java] Eclipse Questions

Started by
7 comments, last by Kevinator 18 years, 7 months ago
Hi guys, I've recently moved to eclipse from Netbeans 3.6 & have a few questions. 1. I've heard of Ant. Does Eclipse use it? What is it for? What does the build.xml do? 2. What is refactor? I know that to refactor is to improve code but why provide a menu for this? 3. I when setting up a project the JDK compliance has 1.4 then 5.0. I see that templates are included in 5.0. Are they much different from C++ templates? Does any1 know of any good links for JDK 5.0 info? Whats so special about this 5.0 release? 4. Does Eclipse have a GUI editor? Thanks for any help!
Reject the basic asumption of civialisation especially the importance of material possessions
Advertisement
Cacks,

I can only fully answer (2), as I've not done anything with Ant myself (though Eclipse is supposed to support something having to do with Ant).

The refactoring feature in Eclipse is very useful. It doesn't have to do with improving your code, so much as changing it consistently.

Suppose you have the variable "x" in your code about 235 times in various functions, methods, etc. You decide after 2 months of development to change "x" to "hitpoints" because it is a more meaningful variable name. You could:

A) Go through your code line-by-line and change all the variable names "x" by hand to "hitpoints";
B) Use Find-Replace to change "x" to "hitpoints"
C) Right-click on an occurance of the variable "x" in your code, select "Refactor," and using that option, rename the variable to "hitpoints"

B and C are the only safe options, because with A you might miss an instance or two. B will work, but sometimes it will catch stuff you don't want, like text, comments, or parts of names (like "extra_lives," etc.). So what you really want is for Eclipse to rename it for you, since it knows what's a variable, what's a comment, what's text, etc., and can do the job cleanly.

That's one reason to use refactoring. Besides variable name changes, you can change the variable type declaration (int to float, etc.), or you can rename a class, or method, or even change a method signature. For example, you can add or remove method parameters ( "foo(int x)" can be changed to "foo(int x, float y)" ). Again, refactoring allows Eclipse to do much of the work for you and reduces the likelihood of your missing an important change--it's much safer for changing things in large projects.
3. Templates and Generics aren't the same thing, read this to find out all you need to know about Generics.
Check out this for a complete view of all new features and/or read J2SE 5.0 in a Nutshell.
J2SE 5.0 (or 1.5) is special because Sun's marketing crew thought so. ;-) Just kidding, it's faster and has a couple of cool new features.

4. Yep, it does. Have a look at the Visual Editor Project.

You're welcome.
Ant is like MAKE for java. Even though eclipse has it's own built in way of building projects, you can optionally use Ant. Configuration for your ant build script is done in XML. There are a lot of things that can plug into Ant, such as testing frameworks like JUnit or TestNG. Ant is nice if you have a large project with multiple build senarios.
So that's what ANT is. XML. Blargh. I'll take Make, thanks. [lol]
You'll like ANT more than make after a very short while.

Cas :)
Quote:Original post by Kevinator
So that's what ANT is. XML. Blargh. I'll take Make, thanks. [lol]


Ant is far superior to make.
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
Quote:Original post by CaptainJester
Quote:Original post by Kevinator
So that's what ANT is. XML. Blargh. I'll take Make, thanks. [lol]


Ant is far superior to make.


...which is saying, um, not much really.

"make was a really good project for a college student [to implement] 20 years ago."
-- Tim Leonard, Intel Massachusetts Microprocessor Design Center
XML is hideous. Everything about it makes me want to vomit.

This topic is closed to new replies.

Advertisement