A summary of Eclipse-related tips

Source: Internet
Author: User
Tags class definition java web

Original: http://licoolxue.iteye.com/blog/619983

Eclipse as a widely used IDE, basic usage tips for everyone will be some, but may not fully explore their potential, perhaps we do not really know this often dealing with the guy, 工欲善其事 its prerequisite, to find some of the eclipse's use of the skills to back up Records, Also hope to be convenient for everyone (article structure may be a bit messy)
Eclipse Code Line statistics
Statistics Total Code line:
Open the File Search dialog box,
Select the regular expression, enter \ n in the search text box
File name Input *.java
Select enclosing projects in the range.
You can then count the number of lines of code for the entire project.
tips for quickly opening files in RCP, for example, open a Word document in Word, or open a PDF file in Acrobat.
This can be achieved through the Org.eclipse.swt.program.Program class of SWT:

String filename = "Myword.doc";
Program.launch (filename);

This class also provides some other useful methods, such as getting an executable program for a particular extension, or even getting an icon for the executable program.
Turn from (http://www.blogjava.net/eclipshine/)


file system out of sync issuesResource is out of sync with the file system solution (GO)
In Eclipse, start the run on server times error:
Resource is out of sync with the file system:
'/test_1_struts_spring_hibernate/webcontent/web-inf/.struts-config.xml.strutside '.
After reviewing the data, it was found that the file system was out of sync because of modifications to the resource in the project outside of Eclipse, but sometimes no modifications were made outside of eclipse, and similar errors were reported.
WORKAROUND: You need to refresh the resource manager manually.
(1) in Eclipse, right-click on the project directory and select F5 (refresh)
(2) Set Eclipse Auto Refresh.
With Window->preferences->general->workspace, check refresh
automatically.


Import plug-in packages from Eclipse into source engineering
Open Eclipse's Pde's plug-ins view to list all plug-ins under current Eclipse, including workspace, to import a plug-in into a project (right-click Import As->source Project)


removing Eclipse's configuration directory causes Eclipse to fail to start a workaround
This is because Equinox can create the configuration directory, but cannot create the config.ini file on its own. When you start eclipse, you need to use the configuration content in Config.ini.
When the configuration is removed, launching eclipse automatically rebuilds the configuration directory.
You can then create a new Config.ini file in the configuration directory yourself, adding the following five elements to the Config.ini file.

Osgi.splashpath = Platform:/base/plugins/org.eclipse.platform
[Email Protected]:start, [email protected]:start, [email protected]
Eclipse.product=org.eclipse.sdk.ide
[Email Protected]/workspace
Eof=eof

After saving the file, restarting eclipse will be no problem.


ifile Drip
Get the absolute path to the IFile file
String path= ifile.getlocation (). Makeabsolute (). ToFile (). GetAbsolutePath ();
IFile goto File
File File =ifile.getlocation (). ToFile ();
Add an item to the new menu group
<extension
Point= "Org.eclipse.ui.perspectiveExtensions" >
<perspectiveextension
Targetid= "Org.eclipse.jdt.ui.JavaPerspective" >
<newwizardshortcut id= "XX. Webprojectwizard "/>
</perspectiveExtension>
</extension>
Where: If setting Targetid = * means applying to all perspectives


Java Web Engineering error Java compiler level does not match the version of the installed Java project facet

This is because the Java version setting in Facted project is inconsistent with the Java version of the project.
Workaround 1:
Eclipse plus VM parameters such as
Create a shortcut to set the target location to D:\ECLIPSE_JEE\ECLIPSE.EXE-VM D:\JAVA\JDK1.5.0_10\BIN\JAVAW


Eclipse plug-in project runs debug report memory overflow resolution



memory overflow during plug-in debugging, tuning JVM parameters, adding memory:

-xms64m-xmx512m-xx:permsize=64m-xx:maxpermsize=128m-xx:+useparallelgc-xx:+heapdumponoutofmemoryerror

(Refer to the JVM parameter Tuning Tutorial: http://niyunjiu.iteye.com/blog/337266)

Eclipse Workset
When all existing items are introduced into the workspace, they are displayed under a folder


Create a working set, select all projects-OK, working sets, Show

In this way, in the Eclipse workspace, all items are displayed as working set.



An inquiry into the organizational structure of Eclipse Workset/project

How does eclipse know how many Workset
The document records that:

${eclipse installation directory}\configuration\.settings\org.eclipse.ui.ide.prefs



The contents of the file are as follows:

#Tue Nov 15:42:15 CST 2008

Recent_workspaces_protocol=3

Max_recent_workspaces=5

Show_workspace_selection_dialog=false

Eclipse.preferences.version=1

Recent_workspaces=f\:\\popularsoft\\eclipse (multiple separated by \ n)

This file affects the "Switch workspce" menu in the Eclipse program

How does each workset know how many works
Each workset corresponds to a directory, which contains the program information, and debug program configuration information, as well as the IDE interface settings information, as well as other plug-in configuration information.

How do you know how many project?

${workset Directory}\.metadata\.plugins\org.eclipse.core.resources\.projects



The directory below the subdirectory below, if there is a ". Location" file, means code engineering.

Note that the actual code may or may not be here.



Typically, when you create a new Java project and select a directory, you are prompted with the name of the project, because you already have a subdirectory with the same names in this directory. You can change the project name at this time.

How to mark a directory for Eclipse project
For Java code Engineering catalogs, there will be a. project file, which is identified as a Java project.

Perhaps Java Dynamic Project also includes special content catalogs, which are also indicated by the project file.

If you build a common Java project and want to move to Java Dynamic Project, just delete the project in Eclipse and do not remove the actual system files or delete the file in this directory note for the later name of the effect can be workset under the project information catalog also deleted.

In addition, for directories that are already Java project, you can import imports into the original or new workset without having to create a new one every time.

A project can be added to multiple workset.
Eclipse (3.3) Advanced tips

When an analogy is large, we use the mouse wheel down to move down sometimes always feel relatively slow, then if we hold the CTRL key and then slide the wheel, then every roll will turn over the entire page, then the speed of the browsing is greatly accelerated.

The refactoring script is added to eclipse, and if the user often has repetitive refactoring, you can then choose Create Script in the Refactor menu to save the current refactoring script, and the next time you want to use it, You can call the script directly using the Apply refactoring in the menu. Do not manually go to the refactoring.

If you copy the entire Java file's source code (including the package structure) inside the Clipboard, then you can choose paste (or CTRL + V) by right-clicking on the Packages Explorer in Eclipse, then eclipse will create a corresponding. Java files, if your Java file source contains the package structure, then the corresponding eclipse will establish the corresponding package folder structure, very convenient and practical.

If you're uncomfortable with the constant color of curly braces and parentheses in Java, you can change the color in Java > Editor > Syntax coloring to the colors you want, and I'm going to change the green.

Workset gives us a special convenient management of the classes that manage the grouping, and now adds a new feature in eclipse that directly puts the check out file into a workset (choose Add Project to a working set), This eliminates the re-establishment of workset steps, indirect utility.

We often use the history view, can easily view a file's historical version record, but the latest version of Eclipse added intelligent search function, according to the text you entered under the list box to find the smart matching content, for example, according to Author,comment, Tag and so on auto match find.
For the already established Wrokset, if we want to directly add or reduce the file of the time, to open edit wrokset for editing, more trouble, now Eclipse has a quick toolbar, you can directly put packager The selected files within the Explorer are added or removed directly.

Some users often edit the code, and the display is not enough space, want to hide toolbar to expand the space, now eclipse provides this new feature, directly on the Eclipse toolbar above the above click Hide Toolbar can hide the toolbar, if you want to display again, Select Show Toolbar on the Windows menu to display it.

In general, the top level of the package Explorer is displayed in project as the top-level directory, even if the selection of a few workset is also the case, we can also select the name of the Workset as the top-level directory to display the structure of project, You just have to select the top Leave Elements---Working sets in the drop-down arrows inside the package explorer, so the Wrokset is more visible and intuitive.

In Eclipse refactoring there is a move option, which typically moves a file from one package to another, but now eclipse simplifies this step by simply dragging it in the Packages Explorer with the mouse to trigger the move refactoring event. That is, when you move a file from one package to another, Eclipse automatically modifies the package structure that refers to the class without needing you to modify it one at a time.

Now eclipse can undo the added task, the bookmark, and so on, in addition to the undo of the code (undo typing), and when you add a task or a bookmark, you can undo them directly in the Edit menu, Very convenient.

We look at the last person who edited it in CVS. Show annotate only the mouse, on the left side of the show number column, to display the corresponding author and version of the information. Now a new feature is the right-click on the number bar on the left to select Show author or show Id under revisions--. Then the number column on the left is displayed directly above the author and version numbers, without the need to put the mouse, at a glance.

In addition to the comparison between the CVS versions that we typically use, Eclipse provides us with a handy local history feature that allows you to record the files you have modified locally, in the edit View page right inside there is (than directly in the file point right-click the history to choose more convenient), in this menu can compare, replace the local current file of the historical code, very useful.
In the Eclipse's Edit menu, the clean up option, which automatically organizes the current Java files into better programming specifications, such as cleaning up unused variables and multi-referenced packages, automatically brackets the IF Else statement (without the added bonus, of course). It is also useful for class variables to access static variables waiting for a series of good coding rules.

The last item inside the clean up is about format code, and if it is selected, you can format it by the way when you clean the up code, more practical options.

Eclipse now can not only set the breakpoint to execute the statement, now can be on the function name above the class definition above the breakpoint, so it is easier to track and debug, such as your breakpoint is set on the class name above, you can see clearly, this class loaded when the order of execution.

Many users in the operation of Eclipse, often mistakenly delete or mistakenly manipulate some files, such as copy, copy files and so on, this time in the new version of Eclipse provides a new undo function, is to let the user pinch the wrong operation when there is somehow opportunity, However, this feature can only be invoked from the system's Edit menu in the Navigator Explorer view.


In the show Annotaion view in the CVS in Eclipse, the previous display on the sidebar was just a different color, and the mouse was placed on the sidebar to show the author and date, and now in show Annotion view inside the right-click menu added in the sidebar display author and comment, date and so on options, very intuitive and convenient.

In Eclipse there is a filter that hides all the reference packages (referenced libraries), but sometimes it's time to look at all the reference packages, even the source structure inside (the latest Eclipse already has this feature), now in eclipse The "Show referenced Libraries Note" option is added to the lower triangle menu in the Package Explorer view, and if the user chooses it, all the reference libraries are placed under this node and can be expanded and shrunk at any time.

Previously only in the Navigator Explorer has a file of the Undo function, now the latest version inside the Package Explorer view also added the file or the deletion of the undo function, then the user from the Edit drop-down menu can be selected.

Now in the Open Resource selection box (ctrl+shift+t) You can select multiple files to open simultaneously.

Reference http://www.blogjava.net/GEF/archive/2007/08/29/140922.html
http://iammr.7.blog.163.com/blog/static/49102699200912665541316/
Http://hi.baidu.com/janneyting/blog/item/a217a63678ef79330b55a973.html
http://chengyu-555.iteye.com/blog/261665

A summary of Eclipse-related tips

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.