Tuesday, June 29, 2010

Creating dependencies between the Projects.

  • Right click on the project you are working on.
  • Go to Properties which will open a Properties window.
  • Go to the Java Build Path.
  • Do Add Folder to add new folders to which have dependiencies.
  • You can add the Libraries also.

Taking the Snapshot of the frontmost window in Windows

Pressing Alt-PrintScreen (Alt-PrtScrn) places an image of the frontmost window on the clipboard. Pressing PrintScreen by itself places an image of the entire desktop on the clipboard.

Friday, June 18, 2010

Unit Testing

Using JUnit tests in Eclipse...

A unit test is a piece of code written by a developer that tests a specific functionality in the code which is tested. Unit tests can ensure that functionality is working and can be used to validate that this functionality still works after code changes.

Installation of JUnit Test

To make JUnit available in your Java project you have to add the JUnit library file to your JavaClasspath.

To do that

  • right click on the Project folder and go to Properties.
  • Under Properties go to the Java Build Path tab under which go to Libraries.
  • Now Do Add Linrary and then select JUnit then Next.
  • Now add JUnit tests version 3 or 4 as you want.
Prepration:

Create a new project . We want to create the unit tests in a separate folder. Create therefore a new source folder "test" via right mouse click on your project, select properties and choose the "Java Build Path". Select the tab source code.

Saturday, May 22, 2010

A Quick Guide for installing Tomcat on Windows


  • After unzipping the file, navigate to the "bin" directory and start Tomcat by running the startup.bat file.

  • You must have the JDK installed before you can start Tomcat. The JDK contains the Java runtime engine.


  • Another point to consider is that JSP pages must be compiled the very first time someone accesses the JSP page. This compilation process converts the JSP page into a Servlet. This requires access to the Java compiler. Tomcat will not be able to call the Java compiler if the directory path to the Java compiler includes spaces. To avoid the problem, install the JDK in a directory with a name that contains no spaces, such as JDK1.3.

  • After starting Tomcat, open your browser and type the following URL: http://localhost:8080. Tomcat uses port 8080 by default, so make sure that port is not being used by another server, such as Internet Information Server (IIS). If there is a port conflict, you can change Tomcat's default port by modifying the file server.xml in the conf directory. Search for the number 8080 in the file and change it to an unused port number. When Tomcat starts successfully, you will see an introduction page for Apache Tomcat.
REFERENCES:

Setting the CLASSPATH of JAVA in Windows Vista

To setup the CLASSPATH of JAVA in Windows Vista
Right Click on My Computer > Properties >Advanced System setting > Environment Variables > System Variables

Add a new System Variable

Variable Name : JAVA_HOME
Variable value : C:\Program Files\Java\jdk1.6.0_16

The value will be wherever you have your JDK installation.

There is a simple test to see if the installation you have done is correct or not.
Go to the command line prompt and type
C:\> java -version
the output will be
java version"1.6.0_17"
Java SE Runtime Environment
Java HotSpot Client VM

The version will be which ever version you have installed. This simple test shows that you have installed the JDK or JRE correctly and have set the class path also correctly.

Java Command Line Arguments in Eclipse

To execute a class having the main method with arguments follow the steps below.

  1. Click from menu bar.
  2. “ Run ” - > “ Run ” and now select “ Arguments tab ”. Text area against “ Program Arguments ” is available to enter arguments. You can add any number of arguments but each parameter should be separated by a space. Space is the delimiter here.


Many people think that comma (,) or semi colon (;) is delimiter but it just a misconception. Delimiter is “ space ”.

Reference:

http://www.eclipse-blog.org/java-se/java-command-line-arguments-in-eclipse-ide.html

Javadoc Basic Tutorial

1. Use following comment style to generate a Javadoc.

/**  
 * Returns .............  
 * 
 * @param  url  an absolute URL   
 * @param  name the location of the  
 * @return      the image   
 * @see         Image  
 */
The first line contains the begin-comment delimiter (/**).
The last line contains the end-comment delimiter (*/) Note that unlike the begin-comment delimiter, the end-comment contains only a single asterisk.

Order of Tags
Include tags in the following order:

* @author      (classes and interfaces only, required) 
* @version     (classes and interfaces only, required. See footnote 1) 
* @param       (methods and constructors only) 
* @return      (methods only)
* @exception   (@throws is a synonym added in Javadoc 1.2) 
* @see          
* @since       
* @serial      (or @serialField or @serialData)
2.Click on projects link and choose ” Generate Javadoc ” option.

3.Now a window will be opened where you can select Java Projects or their underlying resources for which JavaDoc needs to be generated. Several other options are also there where user can select any of them as per the need.Here user can select whether to generate JavaDoc for public/private API’s etc.

To Generate the Javadoc you need to have JDK installed. The JRE won't work since it's a compact version so they do not provide the Javadoc functionality.
The Javadoc command will be the Javadoc.exe which is located in the bin folder of the JDK installation.

4.Now IDE asks for other features as well for the generation of Javadoc.

5.You can also save settings as ant script so that you can use the script to generate javadoc in future.

6.Click “Finish” Javadoc will be generated. If you select option of opening index file in browser then after generation of Javadoc you will find ” index.htm ” of Javadoc in your default Web Browser. On console you can see progress of JavaDoc Generation.