Java Interview Questions and Answers on tools
Related reads:
- MobaXterm Unix emulator for FTP, TFTP, HTTP, Telnet, SSH, VNC and even NFS and more plugins.
- Eclipse debugging tutorial step by step.
- 5 eclipse IDE tips you must know
Q. Can you describe some real life scenarios in which tools helped you solve issues?
A. [Hint: The objective is to ascertain, if you are using the right tool for right job. This question can also be phrased differently with How would you go about ....? type of questions like How would you go about fixing a memory or resource leak in a JEE application?, etc ].
1. Debugging: The application and server logs are the first place to turn for any issues in production or during development. It is really worth understanding some of the tools that will help to obtain, analyze and search through the logs.
- FileZilla or WinSCP to transfer files using FTP, SFTP or SCP protocols. Log files or database extract files can be transferred from a Unix machine to your sandbox (i.e. local machine) using these utilities, and explored further using text editors like Notepad++, UltraEdit, or TextPad. These text editors provide handy features like search text highlighting, REGEX based searches, column formatting, compare files, and many more. Notepad++ has powerful editing features, uses less CPU, and opens larger files.
- Cygwin, MobaXterm or MSYS to emulate Unix like environment for Windows. Many production systems are Unix/Linux based, and having a Unix/Linux environment on your local environment can make you more productive by harnessing the power of Unix commands.
cat /var/log/server.log | grep "login.jsp" | grep "userid"List all the log files that have a particular search text.
grep -l "Missing Characteristic Value" *.log*
You can use regular expression patterns to search.
grep -e '^import.*util.regex' *.java
Find all occurrences of util.* packages except the util.regex package.
grep -e '^import.*util' *.java | grep -v 'regex'
- Remote debugging: It is increasingly essential with the globalization to be able to debug a Java application that is deployed remotely, in another country or city. You will come across scenarios where an application might be running fine in your sandbox (i.e. local desktop), but might be buggy when running in another environment or country.
Say you want to remotely debug an application called MyApp.jar that is running remotely, you can set up your desktop to be able to debug it by enabling the remote debugging as shown below:
java -Xdebug -Xrunjdwp:transport=dt_socket,address=888,server=y -jar MyApp.jar
The above command tells the MyApp.jar to start a server socket on port 888, and publish the debugging messages using the jdwp, which stands for Java Debug Wire Protocol. The IDEs like eclipse can be configured to tap in to remote debugging as shown below.
In eclipse, select Run --> Debug Configurations. Right click on "Remote Java Application", and select "New". Fill in the config details as shown below and apply the changes. Click on the "Debug" button to start debugging the remote application within eclipse. You will have to attach the source files from within eclipse.
The "diagnostic-core" is the project with the source files within eclipse. The "MyApp" is the remote debug configuration that can be stopped and started within eclipse. The connection properties provide information as to where to look for debug messages exposed via jdwp.
- Web debugging tools like Fiddler2 for IE, Firebug NET tab for Firefox, JMeter HTTP proxy server, Charles web debugging, etc act as a proxy to capture request parameters, request/response content, headers, cookies, etc for debugging purpose.
- SQL proxy drivers like P6SPY, log4jdbc, etc to log generated SQL statements, execution times, etc.
- Network packet sniffing tools like Wireshark, Kismet, tcpdump, etc for analyzing the network protocols & issues. Developing applications that interact with web services presents a unique set of problems like not knowing exactly what message was sent to the server, or what response was received. Some of the most difficult bugs to track down are caused by a disconnect between what you think you are sending to the server, and what is actually going across the wire. These tools are commonly called "packet sniffers" and capture all network packets that move across your network interface. Examining the contents of these packets and the order in which they were sent and received can be a useful debugging technique.
- HermesJMS is an extensible console that helps you interact with JMS providers making it simple to publish and edit messages, browse or search queues and topics, copy messages around and delete them.
- soapUI is a functional testing tool for SOA and Web Service testing. soapUI provides complete test coverage - from SOAP and REST-based Web services, to JMS enterprise messaging layers, databases, Rich Internet Applications, and much more.
- Firefox poster plugin is a developer tool for interacting with web services and other web resources that lets you make HTTP requests, set the entity body, and content type. For example, you can make RESTful service calls over HTTP by posting XML.
3. Version control: CVS and Subversion are the two most prominent open source version control tools. TortoiseCVS and TortoseSVN let you work with files under CVS and SVN version control systems directly from Windows Explorer. With these tools you can directly check out modules, update, commit and see differences by right clicking on files and folders within Explorer. You can see the state of a file with overlays on top of the normal icons within Explorer. It even works from within the file open dialog.
4. Performance testing: JMeter is a popular performance testing tool for testing web applications, web services (both SOAP and RESTful), and SQL query performance.JMeter Interview Questions and Answers
5. Hot deployment tools like JRebel, improves developer productivity by skipping the build and redeploy phases in your sandbox. JRebel is a JVM agent, which instantly reloads your code upon change without having to restart your application server or redeploy the application. It integrates into your JVM as a classloader extension and enables reloading of classes without requiring to create a new classloader, which is usually the case when redeploying or restarting application servers.
6. Database administration and SQL execution tools such as db-visualizer, SQuirreL SQL, SQL Developer, DBArtisan, and Toad.There are command-line tools like iSQL for Sybase and SQLPlus for Oracle. BCP (stands for Bulk CoPy) and SQL Loader are ETL (i.e. Extract Transform and Load) tools to import data from a flat file into a database and export data from a database into a flat file.
7. Penetration testing or "PEN test" tools like Google's Skipfish, Firefox plugin "tamperdata", etc to identify security holes in your web application.
Q. What are some of the frequently used short-cut keys on your favorite IDE?
A. The less you touch the mouse, the more code you can write. For example, in eclipse, the following short-cut keys are very handy and makes you more productive.
1. CTRL + SHIFT + R to open a resource and CTRL + SHIFT + T for Java type
2. F4 on highlighting a class or interface to open the type hierarchy.
3. CTRL + SHIFT + O to organize imports
4. CTRL + SHIFT + F to format text.
5. CTRL + D to delete a row
6. CTRL + SHIFT + / to comment out code.
7. CTRL + 1 is probably the most useful one. It activates the quick fix.
8. CTRL + SHIFT + G to generate getters and setters.
9. CTRL + O to get a snapshot of the class members. You can go directly to a member (method, variable) of a huge class file with this. If you just want to jump from one member to the next (or previous), you can use Ctrl + Shift + downarrow or Ctrl + Shift + uparrow, respectively.
10. CTRL + L to go to a particular line. Handy when the stack trace says that the error is on line 256.
11. CTRL + SHIFT + L to get the list of all the currently defined short-cut keys.
12. Pressing down the CTRL key while hovering over a class, interface or a method with the mouse to invoke the contextual menu to navigate to a particular interface, implementation, or method. Very useful.
Q. Name a feature in your favorite IDE that you discovered recently or find it very useful?
A. In eclipse, the "working sets" are very handy concept to categorize resources across projects into a contextually relevant representation. Working sets are simply, as their name suggests, a sub-set of files, classes, folders or projects with the following benefits.
- Categorize multiple projects together that may represent a single application. For example, maven multi-module projects like myproject-core, myproject-web, myproject-batch, myproject-parent, myproject-schedule, etc can be grouped into a single working set named "myproject".
- You can search or access resources by working sets. You can even close the whole working set.
- If you like, you can also create working sets by layers -- Model, View, Controller, Service, DAO, etc. It is also possible to select particular packages, classes, and folder structures to be included or excluded from a given working set. This allows developers to organize code anyway they want.
- Very handy and useful especially in larger projects.
You can get the production support team to email you a stack trace, and then you can copy and paste the stack trace into Eclipse's Console window for further analysis. You can then click on class names in the stack trace as if your own code had generated it.
There are other productivity improving features described above in terms of short-cut keys, especially the ctrl-1 for quick fix.
The "templates" are very handy for frequently used code snippets. The window --> preferences --> Java --> Editor --> Templates can be used to add handy code snippets to improve productivity. For example, the following template to declare loggers.
${:import(org.apache.commons.logging.Log, org.apache.commons.logging.LogFactory)} private static final Log LOG = LogFactory.getLog(${enclosing_type}.class);
You can name the above template snippet as "logger" and when you are inside your class, if you type "logger" and then ctrl+space, eclipse will generates and inserts the required code based on the saved template.
private static final Log LOG = LogFactory.getLog(TestSpring3.class);
Many other useful templates can be created for productivity.
Other similar links:
- MobaXterm Unix emulator for FTP, TFTP, HTTP, Telnet, SSH, VNC and even NFS and more plugins.
- Eclipse debugging tutorial step by step.
- 5 eclipse IDE tips you must know
Labels: Tools
1 Comments:
Great! thanks for the share!
Post a Comment
Subscribe to Post Comments [Atom]
<< Home