Tips to speedup Eclipse IDE
1. Disable Validation : Open Preferences, search validation, select general->validation, disable all validation, click on apply and ok button.
3. Disable Spell check : Open preferences, search spell, select general->Editors->Text Editors->Spelling, uncheck enable spell checking, click apply and ok button.
4. Close inactive/ non-working projects
5. Change/create new workspace after 10 or 15 projects
6. Increase Heap size : http://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse%3F
7. Disable Build Automatically
8. Remove Unwanted Plug-ins
================================
2. Disable Startup Items : Open Preferences, search startup, select general->startup and shutdown, disable plug-ins which you don't require on startup, click on apply and ok button.
3. Disable Spell check : Open preferences, search spell, select general->Editors->Text Editors->Spelling, uncheck enable spell checking, click apply and ok button.
4. Close inactive/ non-working projects
5. Change/create new workspace after 10 or 15 projects
6. Increase Heap size : http://wiki.eclipse.org/FAQ_How_do_I_increase_the_heap_size_available_to_Eclipse%3F
7. Disable Build Automatically
8. Remove Unwanted Plug-ins
================================
Error starting JBoss 5.1.0 GA from within Eclipse Java EE
Failed to boot JBoss:
java.lang.IllegalStateException: Incompletely deployed:
DEPLOYMENTS IN ERROR:
Deployment "AttachmentStore" is in error due to: java.lang.IllegalArgumentException: Wrong arguments. new for target java.lang.reflect.Constructor expected=[java.net.URI] actual=[java.io.File]
DEPLOYMENTS MISSING DEPENDENCIES:
Deployment "ProfileServiceDeployer" is missing the following dependencies:
Dependency "AttachmentStore" (should be in state "Installed", but is actually in state "**ERROR**")
Deployment "ProfileService" is missing the following dependencies:
Dependency "jboss.kernel:service=KernelController" (should be in state "Installed", but is actually in state "**ERROR**")
Dependency "ProfileServiceDeployer" (should be in state "Installed", but is actually in state "Instantiated")
Deployment "ProfileServiceBootstrap" is missing the following dependencies:
Dependency "ProfileService" (should be in state "Installed", but is actually in state "Instantiated")
Dependency "jboss.kernel:service=Kernel" (should be in state "Installed", but is actually in state "**ERROR**")
Deployment "ProfileServicePersistenceDeployer" is missing the following dependencies:
Dependency "AttachmentStore" (should be in state "Installed", but is actually in state "**ERROR**")
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.internalValidate(AbstractKernelDeployer.java:278)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.validate(AbstractKernelDeployer.java:174)
at org.jboss.bootstrap.microcontainer.ServerImpl.doStart(ServerImpl.java:142)
at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:450)
at org.jboss.Main.boot(Main.java:221)
at org.jboss.Main$1.run(Main.java:556)
at java.lang.Thread.run(Unknown Source)
23:10:46,714 INFO Runtime shutdown hook called, forceHalt: true
23:10:46,717 INFO Shutdown complete
Shutdown complete
Halting VM
Solution
Its a JBoss issue. The resolution is, in the jboss-5.1.0.GA\server\default\conf\bootstrap, you will find profile.xml. Please edit, and include java.io.File
<bean name="AttachmentStore" class="org.jboss.system.server.profileservice.repository.AbstractAttachmentStore">
<constructor><parameter class="java.io.File"><inject bean="BootstrapProfileFactory" property="attachmentStoreRoot" /></parameter></constructor>
<property name="mainDeployer"><inject bean="MainDeployer" /></property>
<property name="serializer"><inject bean="AttachmentsSerializer" /></property>
<property name="persistenceFactory"><inject bean="PersistenceFactory" /></property>
</bean>
======================================================
Problem :-
SEVERE: Error loading WebappClassLoader
context: /MyEclipseProject
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@3344c133
servlet.StartServlet
java.lang.ClassNotFoundException: servlet.StartServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1128)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:827)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Solution :-
Please remove the tomcat server runtime library from your project build path and then add only servlet api jar.
======================================================
Improving Code Quality with PMD and Eclipse
PMD works by scanning Java code and checks for violations
How to install it?
- Launch Eclipse.
- Navigate to Help | Software Updates | Find and Install...
- Select "Search for new features to install" and click Next
- Click New Remote Site...
- Enter a name (PMD) and the URL http://pmd.sourceforge.net/eclipse
6. In Sites to include in search check PMD and click Finish
7.In the Search Results dialog check PMD for Eclipse 3 3.1.0 and click Next
8.Accept the terms of the license agreements and click Next
9 Click Finish.
10 Wait for Eclipse to download the required jar files, then click Install
11 Restart the workbench. This will load the PMD plugin.
12 Navigate to Window | Show View | Other...
13 Select PMD | PMD Violations
14PMD Violations view should appear at the bottom pane
How to use it?
Before launching Eclipse make sure you have enough memory for PMD.
- Launch Eclipse
- If you have previously created a Java Project, skip to Step 6. Otherwise click File | New | Project...
- Select Java Project and click Next
- Enter a project name (QA Project) and leave everything else in the default state.
5. Click Finish. Eclipse will ask if you want to switch to the Java Perspective. Click Yes.
6. In the Package Explorer right-click on QA Project and select New | Class
7. In the following dialog enter the class name as Ying and click Finish
8.A new class Ying is created in project's default package. Paste the following code into the new class:
public class Ying { private static final String gOOD = "GOOD"; public void StartSomething() { System.out.println("Hello PMD World!"); } public String thisIsCutAndPaste(String pFirst, int pSecond) { System.out.println("New world"); return "New world"; } }
9.Similarly, create a second class Yang and paste the following code:
public class Yang extends Thread { public Yang(String str) { super(str); } public void run() { for (int i = 0; i < 10; i++) { System.out.println(i + " " + getName()); try { sleep((long) (Math.random() * 1000)); } catch (InterruptedException e) { } } System.out.println("DONE! " + getName()); } public void WRITE_SOMETHING(String INPUT_PARAMETER) { System.out.println(INPUT_PARAMETER); } public static void main(String[] args) { new Yang("Good").start(); new Yang("Bad").start(); } public String thisIsCutAndPaste(String pFirst, int pSecond) { System.out.println("New world"); return "New world"; } }
In the Package Explorer right-click on QA Project and select PMD | Check Code With PMD
Wait for PMD to scan Ying and Yang
If PMD Violations view is not open navigate to Window | Show View | Other... and select PMD | PMD Violations
In the PMD Violations view notice a list of violations. PMD allows violations be filtered by priority.PMD assigns priorities from 1 to 5 and each priority is represented by a colored square at the top-right corner of the view. These little squares are actually clickable on-off switches used to control the visibility of the violations they represent.
Finding Cut and Paste Code
- In Package Explorer right-click on QA Project and select PMD | Find Suspect Cut And Paste
- PMD creates a folder reports under QA Project and stores the result text file
- Select Window | Show View | Navigator
- In Navigator view click on QA Project and then on the reports folder
- The report file cpd-report.txt should look like this:
Generating Reports
- In Package Explorer right-click on QA Project and select PMD | Generate reports
- PMD creates a folder reports under QA Project and stores four report files
- Select Window | Show View | Navigator
- In Navigator view click on QA Project and then on the reports folder
- Of the four report files pmd-report.html should look like this:
# | File | Line | Problem |
---|---|---|---|
1 | Yang.java | 8 | System.out.print is used |
2 | Yang.java | 14 | System.out.print is used |
3 | Yang.java | 17 | Method name does not begin with a lower case character. |
4 | Yang.java | 17 | Method names should not contain underscores |
5 | Yang.java | 17 | Parameter 'INPUT_PARAMETER' is not assigned and could be declared final |
6 | Yang.java | 18 | System.out.print is used |
7 | Yang.java | 21 | Parameter 'args' is not assigned and could be declared final |
8 | Yang.java | 27 | System.out.print is used |
9 | Ying.java | 1 | Each class should declare at least one constructor |
10 | Ying.java | 3 | Avoid unused private fields such as 'gOOD' |
11 | Ying.java | 5 | Method name does not begin with a lower case character. |
12 | Ying.java | 6 | System.out.print is used |
13 | Ying.java | 9 | Parameter 'pFirst' is not assigned and could be declared final |
14 | Ying.java | 9 | Parameter 'pSecond' is not assigned and could be declared final |
15 | Ying.java | 10 | System.out.print is used |
Customizing PMD
The easiest way to begin customizing PMD is by playing with existing rules. Adding new rules is also possible as well as removing unnecessary ones, however these require more knowledge. Since experimenting with existing rules is the easiest, it makes sense to start with them.
Each PMD rule has six attributes:
- Rule name - immutable
- Rule implementation class - immutable
- Priority
- Message
- Description
- Example
Of these six attributes the first two are immutable - they cannot be customized by users. While Message, Description and Example are text-based properties and can accept any String data, Priority is an integer field ranging from 1 to 5.
PMD stores rule configuration in a special repository referred to as the Ruleset XML file. This configuration file carries information about currently installed rules and their attributes. Changes made through the Eclipse Preferences page are also stored in this file. In addition, the PMD Preferences page allows exporting and importing Rulesets which makes them a convenient vehicle for sharing rules and coding conventions across the enterprise.
Before starting the customization it may be a good idea to back-up existing configuration.
- Navigate to Window | Preferences... | PMD | Rules configuration
- Click Export rule set...
- Enter a file name e.g. pmd-rules.xml and click Save
- Back in the Rules configuration page scroll-down and click on SystemPrintln rule
- With the rule selected, click the Priority column and change the priority from Error (2) to Information (5)
- With the rule still selected, click the Edit rule... button on the right
- Change the Message, Description and Example. Click OK when done
- Click Export rule set...
- Enter a new file name e.g. pmd-rules-customized.xml and click Save
- Compare the two XML files - they are different
- In Package Explorer right-click on QA Project and select PMD | Clear PMD Violations
- In Package Explorer right-click on QA Project and select PMD | Check Code With PMD
- Wait for PMD to finish the scan
- If PMD Violations view is not open navigate to Window | Show View | Other... and select PMD | PMD Violations
- Notice SystemPrintln is now priority 5
Adding New Rules
PMD allows new rules in two formats: Java-based rules where the rule is written as a Java implementation class and XPath rules where the rule is defined in an XML file. Both ways are equally applicable and the choice is probably a matter of preference. This article will demonstrate creating a new rule with both Java and XPath. The rule, ParameterNameConvention, will be a simple coding convention checker making sure all method parameters start with a lowercase "p". To accomplish its task the rule will take advantage of regular expressions and will enforce the following expression to all method parameters: [p][a-zA-Z]+. Later this expression will be made into a rule property which will allow further customization by rule users.
This is all good, but before going any further into the custom PMD rules let's see how this PMD thing actually works.
How PMD works?
PMD relies on the concept of Abstract Syntax Tree (AST), a finite, labeled tree where nodes represent the operators and the edges represent the operands of the operators. PMD creates the AST of the source file checked and executes each rule against that tree. The violations are collected and presented in a report. PMD executes the following steps when invoked from Eclipse (Based on PMD's documentation):
- The Eclipse PMD plugin passes a file name, a directory or a project to the core PMD engine (Also part of the Eclipse plugin, however housed in a separate package). This engine then uses the RuleSets as defined in the PMD preferences page to check the file(s) for violations. In the case of a directory or project (multiple source files) the plugin executes the following steps for each file in the set.
- PMD uses JavaCC to obtain a Java language parser
- PMD passes an InputStream of the source file to the parser
- The parser returns a reference of an Abstract Syntax Tree back to the PMD plugin
- PMD hands the AST off to the symbol table layer which builds scopes, finds declarations, and find usages
- If any rules need data flow analysis, PMD hands the AST over to the DFA layer for building control flow graphs and data flow nodes
- Each Rule in the RuleSet gets to traverse the AST and check for violations
- The Report is generated based on a list of RuleViolations. These are displayed in the PMD Violations view or get logged in an XML, TXT, CSV or HTML report.
===================================================
JD – Java decompiler
How to use java decompiler in Eclipse?
first you need installation and activation of JD decompiler in eclipse
- In main menu select Help > Install new software…
- Click on the [Add...] button and input in the pop-up form Name=”JD decompiler”, Location=”http://jd.benow.ca/jd-eclipse/update”; Click on the [Ok] button.
- Select from the “Work with” drop-down list just created item – JD decompiler…
- Click on the [Select All] button and click on the [Next >] button.
- Go through the installation wizard and in the end of it you will need to restart the Eclipse.
But if JD decompiler doesn’t work?
then perform the following steps:
No comments:
Post a Comment