When you develop a java project use eclipse, you may find that the eclipse project runs so slowly, this can even stop your work, you can do nothing but wait for the eclipse project build or download maven jar files to complete. Why is eclipse so slow when building a workspace? This article will tell you some tips about how to avoid eclipse building workspace slow issue.
1. Uncheck Project Auto Build.
If you check the project auto-build menu item, the project will build automatically every time when you change the source code. This can slow down your project coding process extremely. So please remember do not to check the Build Automatically menu item. Below are the steps to disable auto build for the eclipse project.
- Click the eclipse Project menu item at the top menu bar.
- Click the Build Automatically sub-menu item to check or uncheck it.
2. Increase Eclipse Used Memory Size.
Eclipse used maximum and minimum memory size are configured in eclipse.ini file. You can find this file in the eclipse installed directory. If you use eclipse on macOS, there is something different, you can read the article How To Change STS Eclipse INI File On macOS to learn how to change its content for macOS.
To make your eclipse project build faster, increase the eclipse used maximum memory size is a method. Below are the steps.
- Open eclipse.ini file.
- Add or change the below data.
-vmargs -Xms256m -Xmx512m
3. Reduce Auto Startup Plug-in Number After Eclipse Startup.
If you reduce the auto startup eclipse plugins number, this can save a lot of time when eclipse startup.
- Click Eclipse —> Preferences ( macOS) or Window —> Preferences ( Windows ) menu item to open eclipse preferences dialog.
- Click the Startup and Shutdown item in the left panel.
- Then you can select the plugins that you want to be activated when eclipse startup on the right side Plug-ins activated on startup list panel.
4. Reduce Build Process Required Validators To Speed Up Compilation.
In development, when you find the eclipse workspace build process is slower and slower, and if the main reason is because of validating static files ( for example validate JS, CSS, XML file, and so on). Then you need to reduce or remove the validators in the eclipse preference validation section.
- Open eclipse preferences dialog.
- Click the Validation menu item in the left panel, then you can enable or disable the related validator by select/deselect the checkbox in the Build column on the right panel.
5. Exclude JS Files From Validation.
If there are big JS files that exist in your java project, and you do not want to validate the JS file content, you can exclude the JS files from validating it.
- Right-click the eclipse java project, click Properties menu item in the popup menu list.
- Click the JSHint menu item in the left panel, then add excluded js files or folders that do not need validation in the right panel.
6.Remove Eclipse Local History Folder.
- Eclipse workspace has a local history folder, this folder is used to track all the changes that happened to this eclipse workspace.
- If there are too much data in the eclipse local history folder then it can make the eclipse project runs slower and slower.
- You can find the eclipse local history data at your eclipse workspace folder .metadata/.plugins/org.eclipse.core.resources/.history.
- You can remove the above eclipse local history folder completely to make eclipse run faster.
- You can also change settings in the eclipse local history configuration panel to make the local history folder size smaller.
- Click the Eclipse —> Preferences ( macOS ) menu item, then click the General->Workspace->Local history in the popup Preferences dialog window left side.
- Then you can check the Limit history size checkbox, and change the Days to keep files, Maximum entries per file, and Maximum file size(MB) value to a lower number.
7. Remove .metadata Folder Or Create A New Eclipse Workspace.
If you find that your eclipse workspace runs still very slow after trying all the above methods. You can use this final method to resolve the eclipse project run slow issue.
Each eclipse workspace has a .metadata folder, the folder is used to store eclipse and project configuration data such as eclipse plugins when startup or shutdown. If you remove the .metadata folder, the eclipse workspace will create a new one when it startup again. And all the settings in the old .metadata folder will be removed.
So you can make your eclipse project far away from hanging by following two methods.
- Create a new workspace and import all existing projects into it.
- Close the current workspace and delete the .metadata folder under the current workspace and open the workspace again in eclipse to create a new .metadata folder.
- If you look into the .metadata folder, you can find there is a .log file in it. You can find the detailed reason why is eclipse so slow or crash from the logging data in this file.