Friday, December 10, 2010
Accessing Services in Windows.
Saturday, October 9, 2010
Difference between the Eclipse Packages.
what are the differences between the following packages:
Helios Packages
Galileo Packages
Ganymede Packages
Europa Packages
This is a question of version.
Here's a quick reference on Eclipse releases and names.
3.0 | 28 June 2004 | |
3.1 | 28 June 2005 | |
3.2 Callisto | 30 June 2006 | |
3.3 Europa | 29 June 2007 | |
3.4 Ganymede | 25 June 2008 | |
3.5 Galileo | 24 June 2009 | |
3.6 Helios | 23 June 2010 | |
3.7 Indigo | 28 June 2011 |
Tuesday, September 14, 2010
How to make a Build.xml in Eclipse ?
After you have made the project and kept all the source files in the src folder do the following steps to make a build.xml .
- Right click on the Project folder and click on Export.
- Click on General which has a option Ant Buildfiles.
- Click next and select the project for which you have to make a Build.xml .
- This will create the Build.xml.
- Right Click on the the Build.xml file and click on Run As.
- Click the Ant Build.. option which will take you to Edit configuration and launch.
- You can select target to execute.
Thursday, September 2, 2010
Windows cannot find '-Dsun.io.useCanonCahes=false'
If you have the following error while you are trying to start the Apache Tomcat server ( My case it was Apache-Tomcat-4.1.37 ). Then you don't have the JAVA_HOME correctly added to the environment variable.
- Right click on My Computer and click on properties.
- Go to the Advanced tab and click Environment Variables.
- Add a new entry to the system variables if the JAVA_HOME does not exists.
- Set the variable value pointing to the place where it is installed.
To compile any of the .java file you can open the command prompt and type
javac classname.java
This will create the classname.class file .
But if the path to the javac compiler is not set the nit will give the following error message although the JAVA_HOME is set:
"'javac' is not recognized as an internal or external command, operable program or batch file."
To rectify the problem add the path of the javac to the path in the Environment variables.
C:\j2sdk1.4.2_18\bin
The other work around to this problem is each time specify the path like:
C:\j2sdk1.4.2_01\bin\javac classname.java
But setting the environment variables is better option.
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
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.
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
- Download and install the Tomcat from http://tomcat.apache.org/
- 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.
- The environment variable JAVA_HOME tells Tomcat where to find your JDK. You can set this system Variable as explained in the other "Setting the CLASSPATH of JAVA in Windows Vista"
- 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.
Setting the CLASSPATH of JAVA in Windows Vista
Java Command Line Arguments in Eclipse
To execute a class having the main method with arguments follow the steps below.
- Click from menu bar.
- “ 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
/** * Returns ............. * * @param url an absolute URL * @param name the location of the * @return the image * @see Image */ |
/**
).*/
) 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)
Wednesday, May 19, 2010
Changing the JRE being used in Eclipse
- Window > Preferences > Java >Installed JREs
- Add the new installed JRE. Check the one you want to use.
- Now go to Window > Preferences > Java > Compiler
- change the "Compiler compliance level" to the one you are using
- Window > Preferences > Java > Compiler and change the "Compiler compliance level" to 5.0
Adding External Library (.jar) in Eclipse
- From the menu select File -> Import -> File system. Select your jar and select the folder lib as target.
- You can either create complete folder structure or selected folder structure only.Select the selected folder structure only option.
- Select your project, right mouse click and select properties. Under libraries select "Add JARs".
- If you find some errors in the import then find the jar in eclipse/plugin folder for the missing jar files.
Difference Between JRE and JDK
JRE (Java Runtime environment) | JDK (Java Development Toolkit) |
It is an implementation of the Java Virtual Machine* which actually executes Java programs. | It is a bundle of software that you can use to develop Java based applications. |
Java Run Time Environment is a plug-in needed for running java programs. | Java Development Kit is needed for developing java applications. |
JRE is smaller than JDK so it needs less Disk space. | JDK needs more Disk space as it contains JRE along with various development tools. |
JRE can be downloaded/supported freely from java.com | JDK can be downloaded/supported freely from java.sun.com |
It includes JVM , Core libraries and other additional components to run applications and applets written in Java. | It includes JRE, set of API classes, Java compiler, Webstart and additional files needed to write Java applets and applications. |
Opening a Existing Project in Eclispe
- New> Java Project
- Project name should be the same as the folder name of the existing project
- Content == Create project from the existing source
- Projects located in the workspace folder must be direct sub folders of the workspace folder
- Select the working set as the folder name as the name of the project folder.
Useful Shorts for Eclipse
- Select all the lines to be commented
- Press Ctrl + /
- To uncomment do the same thing
- Select the function you want to see the code for.
- Press F3 or right click and do Open Deceleration
- Select the Code to be indented properly
- Press Ctrl + i
- Press Ctrl + o
Tuesday, May 11, 2010
JUnit to test Java Programs
There are three things you must do as you set up this class in order to run your tests:
- Import junit.framework.*.
- Extend TestCase.
- Provide a constructor with a single String parameter. This constructor should call the TestCase constructor with the parameter.
Here is a minimal class that demonstrates the structure of classes derived from TestCase:
import junit.framework.*;
public class XTest extends TestCase {
public XTest(String name) {
super(name);
}
public void Y() { ......... }
}
Monday, May 10, 2010
Eclipse Basic Help
- File>New>Java Project
- Right click on the new created folder by the Java
- New>Package
- Now add the new Java Package name.
- You can use dots (.) to specify multiple folders.
- After the package is added you will see a Tree Hierarchy of the folders which you can see when you go to the folder or when you add the class file inside it.
- Right click on the last folder and click NEW> Class
- This will create the new class for the project.
- To run your Java program outside of Eclipse you need to export it as a jar file. Select your project, right click on it and select "Export".
- Select JAR file, select next. Select your project and maintain the export destination and a name for the jar file. I named it "myprogram.jar".
- From the menu select File > Import > File system. Select your jar and select the folder lib as target.
- Select your project, right mouse click and select properties. Under libraries select "Add JARs".
- If you find some errors in the import then find the jar in eclipse/plugin folder for the missing jar files.
- Window > Preferences > Java >Installed JREs
- Add the new installed JRE. Check the one you want to use.
- Now go to
- Window > Preferences > Java > Compiler
- change the "Compiler compliance level" to the one you are using
- Window > Preferences > Java > Compiler and change the "Compiler compliance level" to 5.0
Saturday, April 17, 2010
Difference Between New & malloc / Delete & free
The difference could be qouted as -
1. Operator new constructs an object (calls constructor of object), malloc does not.
2. Operator new is an operator, malloc is a function.
3. Operator new can be overloaded, malloc cannot be overloaded.
4. Operator new throws an exception if there is not enough memory, malloc returns a NULL.
5. Operator new[] requires to specify the number of objects to allocate, malloc requires to specify the total number of bytes to allocate.
6. malloc() returns void *, which has to be explicitly cast to the desired type but new returns the proper type.
7. Operator new/new[] must be matched with operator delete/delete[] to deallocate memory, malloc() must be matched with free() to deallocate memory.
8. The new/delete couple does not have a realloc alternative that is available when malloc/free pair is used. realloc is used to resize the length of an array or a memory block dynamically.
Friday, April 16, 2010
XHTML
XHTML is a combination of HTML and XML (EXtensible Markup Language).
XHTML consists of all the elements in HTML 4.01, combined with the strict syntax of XML.
XML is designed to describe data, and HTML is designed to display data.
The Most Important Differences:
- XHTML elements must be properly nested
- XHTML elements must always be closed
- XHTML elements must be in lowercase
- XHTML documents must have one root element