Tuesday, September 14, 2010

How to make a Build.xml in Eclipse ?

Making a Build.xml in eclipse is very easy and it can be done in just a few button clicks.

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.
Now if you want to clean or build the project do the following steps:
  • 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.
Video Reference : https://eclipse-tutorial.dev.java.net/visual-tutorials/generatingantbuildfile.html

Thursday, September 2, 2010

Windows cannot find '-Dsun.io.useCanonCahes=false'

Windows cannot find '-Dsun.io.useCanonCahes=false'. Make sure you typed the name correctly, and then try again. To search for a file , click the Start button, and then click search.

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

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.