Showing posts with label Eclipse. Show all posts
Showing posts with label Eclipse. Show all posts

Wednesday, January 8, 2020

Setting up Lombok with SpringToolSuite and Intellij Idea

Lombok is a java library that you can plug into your editor which will automatically generate code in .class file instead of in source file.
E.g:  getters, setters toString, equals, hashcode, builder, loggers, and many others.

In this tutorial, I’ll talk about configuring it in two of the most popular IDEs- IntelliJ IDEA and Spring Tool Suite.

Check my Github repo to learn project Lombok using java source code.

Note: Step for installing the plugin for Eclipse and Spring tool Suite (STS) are the same.

Steps to configure Lombok in STS

  • Download Lombok jar from the Lombok site.
  • Double click on Lombok jar which will open below Installer wizard, Choose IDEs in which you want to install. If your not IDE is not listed then you can browse using Specify location tab.

  • Once selected, click on Install/update button and you are done.

Steps to configure Lombok in IntelliJ IDEA

  • Open IntelliJ Idea and click on File-> Settings…
  • Click on Plugin option and then search for Lombok
  • Click on the Install button on the plugin page

  • Once done with the installation, click on the restart IDE button.

Wednesday, August 13, 2014

How to upgrade ANT in Eclipse ?

To upgrade the ANT into the Eclipse, First you need to download the latest version of ANT anywhere on you machine.
Once you are done with the download then go to
EclipseWindowsPreferencesAntRuntimeAnt Home and Select the downloaded folder.

Now your Eclipse will use the latest version of ANT :)

Thursday, October 17, 2013

How to create Spring MVC project using Maven and Eclipse

This blog will show you how quickly you can  create a Spring MVC project and get it up and running, using the Maven archetype called spring-mvc-archetype.

Note: First You should verify that the Maven Integration for FTP is already installed in your eclipse, If not first installed and then create a new project.

Steps :
  • In Eclipse IDE, Goto  File > New > Project
  • Select Maven > Maven Project and click Next.
  • Make sure you don’t check the option Create a simple project (skip archetype selection), and click Next. In the next screen,
  • Select Catalog as All Catalogs, Archetype as spring-mvc into the Filter  and select maven-archetype-webapp in the artifact list as shown below :


In case, If you don't see the above artifact in your Archtype then Click on "Add Archetype" and Add :
    • Archetype Group Id: co.ntier
    • Archetype Artifact Id: spring-mvc-archetype
    • Archetype Version: 1.0.2
    • Repository URL:\
Click Next and Enter Group Id (e.g. Test), Artifact Id (e.g. Test), Version (e.g. 1.0) and Package (com.waheed.test), as shown below :

Click Finish.Finally you have a project structure looks like below:                         


Tuesday, April 9, 2013

Eclipse - Tips & Tricks

This article is for those who use Eclipse. Keyboards shortcuts are very important for comfortable and quick editing. Here are the list of most important shortcuts in Eclipse :
For a full list of shortcuts, you can also check by pressing Ctrl+Shift+L.
  1. Ctrl +3 Focus into the Quick Access search box which allows you to execute any Eclipse command.
  2. Ctrl+SHIFT+T Search dialog for Java Type, Start typing the name and the list gets smaller. Try typing the capital letters of the class only (e.g. type "NPE" to find "NullPointerException")
  3. Ctrl+SHIFT+R Search dialog for resources, e.g. Xml files, text files, or files of any other type.
  4. Ctrl+E Open Editor Drop down, Presents a popup window listing currently opened files.
  5. Ctrl+O Quick Outline, Show all methods of the current class, Press Ctrl+O a second time to include inherited methods.
  6. Ctrl+SHIFT+space Context Information
  7. Ctrl+Shift+O Organize Imports, Adjusts the imports statements in the current Java source file
  8. F3 Open Declaration ,Navigate to the declaration of the selected variable . This works much like a browser hyperlink.
  9. Ctrl + hover to methods,variables Ask for Open Declaration, Implementation, Super Implementation or return types.
  10. Alt+Left/Right Backward/Forward History, Works like a browser's back/forward button.
  11. Ctrl + L Go to a specific line number.
  12. F4 Open Type Hierarachy
  13. Ctrl+Alt+H Open Call Hierarchy. Show where a method is called from.
  14. Alt + SHIFT + R Use this to rename type, method, or field. All existing references will be refactored as well.
  15. Alt+Shift+M Extract method, Use this to extract a new method from existing code. The parameter list and return type will be automatically created.
  16. Ctrl+Shift+P Go to the matching bracket.
  17. SHIFT+ENTER /Ctrl+SHIFT+ENTER Insert a line below or above the current line.
  18. Ctrl + /, Ctrl+7, Ctrl +\ Add or Remove block comment.
  19. Ctrl +F6 Switch among the editor.
  20. Ctrl + F7 Switch among open views.
  21. Ctrl + F8 Switch among perspectives.
  22. Alt +/ It does the word completion based on the set of words already present in the current file.
  23. Ctrl + I It correct the indention for block of Java code or an entire class.
  24. Ctrl + . or Ctrl + , It will navigate to next or previous error.
  25. Ctrl+F11, F11, Run or Debug the Application.
  26. F5,F6, F7, F8 Step into function, Next Step (line by line) , Step out , Skip to next breakpoint.
  27. Ctrl +1 Give quick fix code.
  28. Ctrl + D Delete the current line.
  29. Ctrl + SHIFT + G Search for current cursor positioned word reference in workspace.
  30. Ctrl +Page Up/Page Down Switch to next editor / switch to previous editor
  31. Alt + - Open Editor Window Option menu.
  32. Ctrl +F10, then n It will show or hide the line numbers
  33. Ctrl + q It will jump to last location edited
  34. Ctrl + SHIFT + f It will format all code in Editor using code formatter.
  35. Alt + SHIFT + J or /** and then press Enter Add javadoc Element Comment ( adds '/** ... */')
  36. Alt + SHIFT + V Move selected element to other class or file (With complete method or class selected)
  37. Ctrl + DEL Delete next element
  38. Ctrl + BACKSPACE Delete previous element. 
    Note : I have not added basic shortcut like Ctrl+S to save the file.
    Feel free to comment If you find something is incorrect or update me more :)

Wednesday, April 25, 2012

Debug Java applications remotely with Eclipse

Remote debugging is a way of debugging any process running on some other location from your development machine. Local debugging is the best way in my opinion and should always be preferred over remote debugging but if local debugging is not possible and there is no way to debug your process then remote debugging is the solution.

Many of us work on a project which runs on Linux operating system and we do development mostly on Windows.
Eclipse provides us most useful feature called "Remote debugging" by using which you can debug your Linux running process from your windows machine.

Now let's see how we can setup remote debugging in Eclipse:

Just take a example of a simple program that we want to be debugged:

package com.tutoial.debugger;

 * @author abdul
public class Debug {
    public static void main(String args[]) {
        for(int i=1; i<=10;i++) {
            System.out.println("2 * "+ i + " = " + 2*i);

Convert it into the jar.
From Eclipse , You can do it by following step:
1. Select the file that you want to export, Right click and choose "export".
2 .Goto Java-> jar and click Next
3. Browse the path where you want to export and click "finish".

Now, In order to remote debug a java application, Start your application with the following JVM debug options:

java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y suspend=y -jar debug.jar

This will start java applicaiton debug.jar into debug mode using Java Debug Wire Protocol (jdwp) protocol and it will listen on port 8000 ,suspend=y will ensure that that application will not start running until eclipse connect it on speicified debug port.

After running it you should see something like that:
          Listening for transport dt_socket at address: 8000

Go to Eclipse and open debug dialog (you can press Alt+R, B). Create a new Remote Java Application Configuration. Select connection type as "Socket attach" and specify Connection Properties (for our example host would be localhost, and port would be 8000).

It also important to note that application must be start before eclipse tries to connect it other wise Eclipse will throw error "Failed to connect to remote VM. Connection refused" or "Connection refused: connect"


Related link:

Wednesday, November 23, 2011

java.lang.IllegalStateException: "Workbench has not been created yet"

I’ve been working with OSGi for quite awhile and have faced a problem "Workbench has not been createt yet" issues. I was getting this error, When i was trying to run OSGI plugin from Eclipse and I guess many of you must have face this problem. So i am writing a little bit about how to resolve this issue so others don’t repeat the same mistakes.

From a good article on eclipsezone:

java.lang.IllegalStateException: Workbench has not been created yet

This usually comes when someone tries to run a Java application against an OSGi bundle with java -classpath .... . It really means that the workbench plug-in hasn't started yet, and so calls to getWorkbench() fail. This is essentially a race condition, and can be solved by either expressing an explicit dependency on that bundle or bumping up that bundle to a higher start level than the workbench. Generally not seen, but if it is, that's what's happening.

Now to set the bundle to a higher start level than the workbench.
Select your, right-click, select Run As-> Run Configuration. Create a OSGi Framework launch configuration. Deselect all bundles except your bundle. Change the default set level to higher level and Press then "Add Required bundles"
Run this configuration. This should give you the correct output.

If you still get the same error ,then you can do
1. Add the -clean to the program Arguments.i,e(Run Configuration->OSGI framework->Arguments ->program Arguments)
                                           OR (Recommended 1 if failed then try 2)
2. Delete the .metadata folder which is created by default in Eclipse Workspace but before that please take the backup..:)

Hope its gonna work for you guys too..Feel free to comment.

Thursday, October 27, 2011

How to install Subversion,Google App Engine,Android with Eclipse.

This is tutorial assumes you already have Eclipse installed.

You can install the any plugin for Eclipse using the Software Update feature of Eclipse.
To install the plugin, using Eclipse:
Select the Help menu > Install New Software....
In the Work with text box, enter:

For Subversion:

For Android:

For Google App Engine:

Eclipse 3.6 (Helios):
Eclipse 3.5 (Galileo):
Eclipse 3.4 (Ganymede):
Eclipse 3.3 (Europa):

Click OK
In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
In the next window, you'll see a list of the tools to be downloaded. Click Next.
Read and accept the license agreements, then click Finish.
Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
When the installation completes, restart Eclipse.

Additional Info:

Friday, May 27, 2011

Error: Unable to open class file and How to fix it.

[2011-05-27 12:12:39 - listActivity] ERROR: Unable to open class file /root/workspace/ No such file or directory

[2011-05-27 13:50:38 - listActivity] ERROR: Unable to open class file /root/workspace// No such file or directory and is a automatically generated file.

The ADT has a few such annoying bugs. But you can sort them out..
What usually helps is:

1. Close Project->Open Project > Build Automatically .
2.Another thing that sometimes helps is right click project > android tools > fix project properties and remove unnecessary content or jar files.

3.Or you can do Project->clean and Refresh .

If still it not generating files then check your class there must be a extra line..

Import*; Remove that and then do all the above one by one..

Hope it help ..

If someone know other way please let me know.



Tuesday, May 24, 2011

Conversion to Dalvik format failed with error 1

Sometime You will encounter this problem when trying to Build Android Project on Eclipse..
 You will get such output in console:

[2011-05-24 09:25:03 - Android C2DM] Dx 1 error; aborting
[2011-05-24 09:25:03 - Android C2DM] Conversion to Dalvik format failed with error 1

You can solve this problem:

Go to Project » Properties » Java Build Path » Libraries and remove all except the "Android X.Y" (in my case Android 2.2). click OK. 
and then
Go to Project » Clean » Clean projects selected below » select your project and click OK.

 That work for me. Hope it works for you too.!!!!

How TOPT Works: Generating OTPs Without Internet Connection

Introduction Have you ever wondered how authentication apps like RSA Authenticator generate One-Time Passwords (OTPs) without requiring an i...