Eclipse IDE, Plugins SonarCube - Yash-777/LearnJava GitHub Wiki

Eclipse IDE for NEON Java EE Developers.

The Eclipse Installer 2020‑12 R now includes a JRE for macOS, Windows and Linux. Eclipse IDE for Enterprise Java Developers

HINT: In order to use Eclipse we need to set JAVA_HOME environment variable with Java runtime environment (JRE). Latest packages come with a JRE.


Spring Tool Suite 4, 3.9.12

Spring new Starter Project
App -> R.c -> Spring - Add Starter

App -> R.c -> Run as - Spring Boot application
App -> R.c -> Run as - Run configuration - Spring Boot application Arguments[--server.port=0] Dynamically assign the port at runtime

applicaiton.properties -> R.C Open with Generic Editor

Monitor HTTP requests and responses using TCP/IP Monitor in Eclipse/STS

show View->TCP/IP Monitor view->: Property->Add Property
	Local Monitoring Port:9999[Host:www.eclipse.org Port:80 Type:HTTP] Start
		Chrome:localhost:9999 Redirect:www.eclipse.org  PROXY:Monitor all N/W calls
	Local Monitoring Port:9999[Host:www.eclipse.org Port:80 Type:HTTP] Start
	Chrome:localhost:9999 Redirect:www.eclipse.org

image

Boot Dashboard

 - SpringBootApp[8080] - R.C Duplicate Config to run new instance with different port
 - SpringBootApp - R.C Open Config - Change Name:8082 with Arguments[--server.port=8082] Apply, close, Restart server

Extract Local Variable: Starts the Extract Variable refactoring dialog. Creates a new variable assigned to the expression currently selected and replaces the selection with a reference to the new variable. This refactoring is available on text selections that resolve to local variables. You can use Expand Selection from the Edit menu to get a valid selection range. https://www.codejava.net/ides/eclipse/8-eclipse-shortcut-keys-for-code-refactoring

EclipseMenu -> Refactor -> Extract local variable
Alt + Shift + L

Increase Eclipse toolbar icon size
Tweaking SWT's auto-scaling: VM argument in eclipse.ini -Dswt.autoScale=false

following added in the eclipse.ini file, making the icons normal:

-Dswt.enable.autoScale=true
-Dswt.autoScale=180
-Dswt.autoScale.method=nearest

Hierarchical view of projects can be triggered from the Project Explorer view menu, under the Projects Presentation item.

Eclipse Plugins

Sonar Qube My Git Wiki, making Code Analyzers - Quality software comes from quality code

FindBugs

FindBugs (as a project) is dead, but development continues under a new name: SpotBugs.

How to run Findbugs in eclipse?: Configure automatic FindBugs run. You can configure that FindBugs should run automatically for a selected project. For this right-click on a project and select Properties from the popup menu. Select FindBugs Run automatically.

SpotBugs SpotBugs is a program which uses static analysis to look for bugs in Java code. SpotBugs is open source (LGPL).

PMD Automated Code Review

PMD is a source code analyzer. It finds common programming flaws like unused variables, empty catch blocks, unnecessary object creation, and so forth. It supports Java, JavaScript, Salesforce.com Apex and Visualforce, PLSQL, Apache Velocity, XML, XSL.

Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code in Java, C, C++, C#, Groovy, PHP, Ruby, Fortran, JavaScript, PLSQL, Apache Velocity, Scala, Objective C, Matlab, Python, Go, Swift and Salesforce.com Apex and Visualforce.

Activate with Java Rules

Use the property dialog of your project(s) to activate eclipse-pmd.

  • If you don't already have a PMD rule set then create a new one.
  • Open the property dialog of your project.
  • Select the PMD property page.
  • Check the Enable PMD for this project checkbox.
  • Add one or more rule sets by clicking the Add... button.
  • Close the property dialog. Your project will now be analysed by PMD.
  • If you have another project where you want to activate eclipse-pmd, continue with step 2.

To pick the latest modified project name in eclipse, By eclipse server Runtime.

Note: Select project and press CTRL + SHIFT + R to open Resource and search for files.

  • org.eclipse.wst.common.component and then change the deploy name.
  • org.eclipse.wst.common.project.facet.core.xml to change project facets.

In Eclipse follow the below specified details. We have to change the hidden prefs of project.

D:\Yashwanth\MyProject.settings\org.eclipse.wst.common.component. eclipse bug id 180741, stackoverflow

When you rename the web application form MyOLDProject to MyProject. You need to make changes as follows.

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="MyOLDProject"> <!-- Dynamic Web Module 3.0 -->
        <wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
        <property name="context-root" value="MyOLDProject"/>
        <property name="java-output-path" value="/MyProject/target/classes"/>
    </wb-module>
</project-modules>

Tomcat Server - Add or Remove Projects - MyProject(MyOLDProject). To Solve the above problem change in the above file.

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="MyProject"> <!-- Dynamic Web Module 2.3 -->
        <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
        <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
        <property name="java-output-path" value="/MyProject/target/classes"/>
        <property name="context-root" value="MyProject"/>
    </wb-module>
</project-modules>

D:\Yashwanth\MyProject.settings\org.eclipse.wst.common.project.facet.core.xml

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <runtime name="Apache Tomcat v7.0"/>
  <fixed facet="wst.jsdt.web"/>
  <installed facet="jst.web" version="2.3"/>
  <installed facet="wst.jsdt.web" version="1.0"/>
  <installed facet="java" version="1.8"/>
</faceted-project>

Change Tomcat Title

In order to changed the title that appears on the top of the Tomcat-console.

Tomcat-Installation Path/bin/catalina.bat

  :doStart « if "%TITLE%" == "" set TITLE=Chenge the title Tomcat

Removing Startup WORK SPACE

  • From File: Go to specified location then Select and Remove work-spaces names which you what to delete.
 Eclipse-Installation Path\configuration\.settings\org.eclipse.ui.ide.prefs
  [MAX_RECENT_WORKSPACES=7
   RECENT_WORKSPACES=WORKSPACE1\nWORKSPACE2\nWORKSPACE3]
  • Through IDE:
   Windows → Preferences → General « Startup and Shutown « Workspaces
       → list of Recent WORK SPACE-Names are available, select one from it and click on [Remove] button.

Eclipse Tomcat Server Creation Problem

In Eclipse if you can't create another instance for Tomcat server of any version, then.

  1. Close Eclipse.
  2. from this location {workspace-directory}/.metadata/.plugins/org.eclipse.core.runtime/.settings delete the following two files: org.eclipse.wst.server.core.prefs org.eclipse.jst.server.tomcat.core.prefs
  3. Restart Eclipse

Select external Web Browser

Through IDE either you can select any of the listed browsers or you can create New by providing → Browser name and Installation location.

Location: Windows → Preferences → General → Web Browser « use external web browser

Show Line Numbers

  1. From File: From this file org.eclipse.ui.editors.prefs change property values to true.
File Location → [work space\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.ui.editors.prefs]
& its Property values →

lineNumberRuler=true
showWhitespaceCharacters=true
  1. Through IDE Window → Preferences → General « Editors « Text Editors [Check/UN check] Show line Numbers.
 CTRL + F10 then N - Show or Hide line Numbers

Enable | Disable Spell Checker

Form this below location where you can enable or disable spell checking by checkbox.


Toggle Mark Occurrences

Ctrl+Shift+O is to organize imports, & Alt+Shift+O is to Toggle Mark Occurances.

  • ToolBar: You can simply use the "Toggle Mark Occurrences" icon on the tool bar or you can use keyboard short cut alt+shift+O.

Tool Bar

  • Preferences Window: Window > Preferences > Java > Editor > Mark Occurrences. Enable "Mark occurrences of the selected element in the current file" and click Apply.

preferences window


Plugins

  • EGit - Git Integration:
http://marketplace.eclipse.org/content/egit-git-integration-eclipse
  • Subclipse support for Subversion:
http://marketplace.eclipse.org/content/subclipse
  • TestNG
http://marketplace.eclipse.org/content/testng-eclipse
  • Android Development Tools
http://marketplace.eclipse.org/content/android-development-tools-eclipse

Runnable Jar file Specifications

After deleting files - Restart the Eclipse IDE to avail changes.

Launch Jar files «

${WORKSPACE}/.metadata/.plugins/org.eclipse.debug.core/.launches/ Delete all the .class LAUNCH Files

If changes not happens means it picked form history files so delete all of them and restart the eclipse.

${WORKSPACE}/.metadata/.plugins/org.eclipse.jdt.core/

Export Destination «

<!-- ${WORKSPACE}/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml -->

<section name="FatJarPackageWizard">
	<item value="${WORKSPACE}" key="FatJarPackageWizardPage.ANTSCRIPT_LOCATION"/>
	<!-- Launch Jar files Default Value -->
	<item value="ClassName - ProjectName" key="FatJarPackageWizardPage.LAUNCH_CONFIGURATION_SELECTION_NAME"/>
	<!-- Launch Jar files Default Value -->
	<item value="D:\Ruunable.jar" key="FatJarPackageWizardPage.DESTINATION_PATH_SELECTION"/>
	<item value="false" key="FatJarPackageWizardPage.ANTSCRIPT_SAVE"/>
	<item value="1" key="FatJarPackageWizardPage.LIBRARY_HANDLING"/>
	<list key="FatJarPackageWizardPage.DESTINATION_NAMES_ID">
		<item value="D:\Ruunable.jar"/>
		<item value="D:\Normal.jar"/>
	</list>
	<list key="FatJarPackageWizardPage.ANTSCRIPT_LOCATION_HISTORY">
		<item value="${WORKSPACE}.xml"/>
		<item value=".xml"/>
	</list>
</section>

WorkSpace assigned Java versions list and its related jar files is maintained in .install.xml and libraryInfos.xml files.

${WORKSPACE}.metadata.plugins\org.eclipse.jdt.launching/.

<!-- install.xml -->
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<dirs>
<entry loc="C:\Program Files\Java\jdk1.6.0_45" stamp="1486642691624"/>
<entry loc="C:\Program Files\Java\jre1.8.0_91" stamp="1484748800139"/>
</dirs>

<!-- libraryInfos.xml -->
<libraryInfos>
	<libraryInfo home="C:\Program Files\Java\jdk1.6.0_45" version="1.6.0_45">
		<bootpath>
		<entry path="C:\Program Files\Java\jdk1.6.0_45\jre\lib\resources.jar"/>
		<entry path="C:\Program Files\Java\jdk1.6.0_45\jre\lib\rt.jar"/>
		<entry path="C:\Program Files\Java\jdk1.6.0_45\jre\lib\sunrsasign.jar"/>
		<entry path="C:\Program Files\Java\jdk1.6.0_45\jre\lib\jsse.jar"/>
		<entry path="C:\Program Files\Java\jdk1.6.0_45\jre\lib\jce.jar"/>
		<entry path="C:\Program Files\Java\jdk1.6.0_45\jre\lib\charsets.jar"/>
		<entry path="C:\Program Files\Java\jdk1.6.0_45\jre\lib\modules\jdk.boot.jar"/>
		<entry path="C:\Program Files\Java\jdk1.6.0_45\jre\classes"/>
		</bootpath>
	<extensionDirs>
		<entry path="C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext"/>
		<entry path="C:\WINDOWS\Sun\Java\lib\ext"/>
	</extensionDirs>
	<endorsedDirs>
		<entry path="C:\Program Files\Java\jdk1.6.0_45\jre\lib\endorsed"/>
	</endorsedDirs>
	</libraryInfo>
	<!-- Jre * version jars list -->
<libraryInfos>
⚠️ **GitHub.com Fallback** ⚠️