Here are a few items that I like to do when I first pick up Eclipse.
By and large, the Eclipse defaults mimic the Code Conventions for the Java(tm) Programming Language from Sun. For some reason, Eclipse uses hard tabs by default. Since most people set their tabs differently, the rule is not to use hard tabs in code.
Go to Windows > Preferences > Java > Editor > Typing:
In a Java file, type a tab character and then use the arrow keys to ensure that you're inserting spaces, not tabs.
Go to Windows > Preferences > Java > Code Style > Code Formatter and click on the Edit button.
Change the following items in Window > Preferences > Java > Compiler > Errors/Warnings to keep the code clean:
This can be a legitimate error, so be careful!
Change the following items in Window > Preferences > Java > Compiler > Javadoc:
These will help you catch errors before JCSC does.
I like to go to Window > Preferences > Java > Task Tags and make XXX as a high priority alias of FIXME. These high priority tags are used for items that should be looked at before the next release while the normal TODO tags are used to mark items that aren't critical.
The assert keyword will generate errors until you set the code version to 1.4. To do this, go to Window > Preferences > Java > Compiler, and:
Now you can use the assert keyword.
I typically check out a project with CVS or Subversion and then use File > New > Project to load it into Eclipse. In the dialog that ensues, ensure that Java Project is selected and click Next. Name the project, deselect the Use default item and enter the path to your checked-out project, unless you've checked it out into the default directory.
I check in the .project and .classpath files (being careful that the paths are relative so others can use it) so that Eclipse will load the project and be nearly ready to go. I also set the build path to build.eclipse to avoid conflicts with my ant environment which sends output into build.
You might need to run ant to build jars or RMI stubs. One way to do this is to use the Run > External Tools menu to call your ant target.
To set this up, run Run > External Tools > External Tools and click on New. Enter a Name. To fill in the Buildfile field, click on Browse Workspace and select the appropriate build.xml file. You should have something like ${workspace_loc:/your-project/build.xml}. Then set the Arguments to -Dbuild.classes=build.eclipse (since we set the output entry in .classpath to build.eclipse above). Select the Targets tab and ensure that the desired target is selected. Then click Run. This also creates a menu item that you can select in the Run > External Tools menu.
Use the pull-down menu on the Run button and choose Run. Select Java Application and use the New button to create a new configuration. Enter the name of your project as the Project and the name of the class that contains main.
Optionally, go to the Argument tab and enter the name of the working directory if it is different from your project directory.
You should now be able to click on the Run button and launch your project.
This is the Eclipse plugin for Subversion. With this plugin you can check in your changes within Eclipse. One of the best features is that you can use Eclipse's refactoring tools for renaming and moving files and packages and the changes are propagated automatically to Subversion.
To install the plugin, use the Help > Software Updates > Find and Install Command. Select the Search for new features to install choice, click Next, click New Remote Site and enter http://subclipse.tigris.org/update as the URL and Subclipse for the Name. The rest of the wizard should be self-explanatory.
Restart Eclipse as directed, and then go into Window > Preferences > Team > SVN. Edit the preferences as desired. Non-windows users will want to either select the SVN command line choice in SVN interface, or install Javahl per instructions in the Subclipse FAQ.
Then, bring up the context menu for your project and run the Team > Share Project item and select SVN in the dialog. The rest should be self-explanatory.
After doing that, you might get an authorization failed message. If so, use the Window > Show View > Other > SVN > SVN Repository command. This brings up an SVN Repository tab down by the Console. Using the context menu on your repository in this view, run the Properties command. Enter your login and password.
You should now be able to use the Team and Compare With menu items.
Non-windows users should install the JavaSVN plugin using the same procedure as was used to install the Subclipse plugin.
Here are some tips that may or may not apply to you.
Your Subversion repository may require that there cannot be any trailing whitespace. Some versions of Eclipse do not remove this space in the Source > Format command. In this case, you can bind a key to execute the Remove Trailing Whitespace command.
Now when you are in an editor, you can just type <Esc>, <Ctrl>+T, and trailing white space will be removed from the text.
Copyright © 2005 Bill Wohler Last modified: 2006-02-05 10:26:44 -0800 (Sun, 05 Feb 2006) About photos |
Free DNS |