Pages

Tuesday, December 31, 2013

java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config

  • When ever this type of  exception occurs check if jstl.jar is present in /WEB_INF/lib folder.
  • Add the jstl.jar to the /WEB_INF/lib folder and restart the sever.This error should disappear.

Tuesday, November 26, 2013

java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

Check if the spring mvc jars and commons-logging jars are present in /WEB-INF/lib folder or else paste
these libraries in this folder

The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

In Eclipse Helios "Java EE Module Dependencies" in the project properties has been replaced with "Deployment Assembly".
In  Eclipse Kepler, the way I did it is the following:
  • Right click on the project in package explorer and choose "Import..."
  • Accept the default selection "File System" and press "Next"
  • Press "Browse" in the From directory line, go to your tomcat installation and locate the file webapps/examples/WEB-INF/lib (I have tomcat 6, other versions of Tomcat may have the path webapps/jsp-examples/WEB-INF/lib). Once in the path press OK.
  • Click besides jstl.jar and standard.jar to activate the check boxes
  • On the line Into folder click on Browse and choose the library folder. I use /lib inside the project.
  • Click "Finish"
  • Right click on the project in Package Explorer view and choose properties (or press Alt + Enter)
  • Click on "Java Build Path"
  • Click "Add Jar", click on your project, folder lib, select jstl.jar, standard.jar and press OK
  • Click "Add Jar", click on your project, folder lib, select standard.jar, press OK
  • Press OK to dismiss the properties dialog
  • Right click on it and select "Quick Fix".
  • Accept the default "Mark the associated raw classpath entry as a publish/export dependency" and press Finish.
  • Do a clean build .The rreors now disappear

Friday, November 22, 2013

How to download youtube videos from firefox

Steps to installer to download the youtube videos
---------------------------------------------------------
1)Click on link to download the add on .
2)Click on Add to Firefox button.This will install the add on to the firefox.
3)Go to youtube and open the video which you want to download .
4)Download link will be available below the video.
5)Click on the small arrow to expand the drop down for more options
6)Happy downloading :)

Sunday, November 17, 2013

Caused by: org.xml.sax.SAXParseException: The prefix "util" for element "util:list" is not bound.

If you get the following error in while executing a Spring program.Following are the steps to resolve it.

Add the namespaces (the ones that are highlighted below in your spring configuration file)

<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns:util="http://www.springframework.org/schema/util"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://www.springframework.org/schema/util
  http://www.springframework.org/schema/util/spring-util-2.5.xsd">

This will resolve the issue





Saturday, November 16, 2013

How to generate setters and getters in java -Eclipse

1)Right click on the member variables in the java class for which the setter and getter values need to be generated.
2)Select source->Generate Setters and getters and click on it
3)Tick  the variables in the pop up box for which setters and getters are to be generated .See the snapshot below.
4) By clicking on OK the respective methods are generated.

Thursday, October 31, 2013

How to import war files into eclipse

To import war files into eclipse,following are the steps.

  1. Select File > Import .
  2. In the Import dialog, select WAR file and then click Next.
  3. Give the location of  WAR file that you want to import using the Browse button.
  4. The wizard assumes you want to create a new Web project with the same name as the WAR file. If you accept this choice, the project will be created with the same servlet version as specified by the WAR file and in the same location. If you want to override these settings, you can click New and specify your new settings in the Dynamic Web Project wizard.
  5. Click Finish to complete the set up.

Sunday, October 27, 2013

How to import java projects in eclipse

1)If you have downloaded a zip file ,then unzip the folder.
2)Go to Eclipse and select File->Import
3)Under General folder select  Existing projects into workspace
4)Click on Next  button.
5)Give the root directory location ,i.e browse to the location of the unzipped folder
6)Click on finish
7)Do a project refresh








The resource is not on the build path of a Java project."

I googled a lot for this error and could not get a proper solution.So i have resolved it my self.

Steps to resolve
-------------------
1)GO to package explorer ,right click on the src folder.
2)Go to Build path and select "Add as source folder"
3)Below is the screenshot.
4)Now the f3 errors,organise imports etc are resolved.
5)If it still doesn't  reflect,go ahead and do a clean build.

Sunday, September 15, 2013

Java Interview questions on exceptional handling

1.)What happens if main() is written with out String args[]?
--The code compiles but JVM cannot run it,as it cannot see the main() with String args[]

2.)What are checked exceptions?
--Exceptions that are checked by compiler at the compilation time are called as checked exceptions.

3.)What are unchecked exceptions?
--Exceptions that are checked by JVM are called as unchecked exceptions.

4.)What is Throwable?
--Throwable is a class that represents  all errors and exceptions that occur in java

5.)What is the superclass for all exceptions?
--Exception is the superclass for all the exceptions.

6)What is the difference between exception and an error?
--Exception is a situation which can be handled using try catch
--Error cannot be handled by the programmer and leads to abnormal program termination.
    Ex: OutOfMemory 

7)Difference between throws and throw?
--throws clause is used when the programmer does not want to handle the exception and throw it out of method.
--throw clause is used when the programmer wants to throw an exception explicitly and wants to handle it using catch block.

8)Can we rethrow an exception??
--Yes ,we can rethrow an exception from catch block to another class where it can be handled

Points on exceptional handling

  •  Exceptions  can be handled using try and catch blocks.
  • A try block can be followed with any number of catch blocks.
  • Statements are not allowed in between try and catch blocks
  • It is possible to handle multiple exceptions using  multiple catch blocks
  • Catch block cannot  exist independently ..it should be preceded with a  try block whereas try block need not be followed compulsorily by catch block ,a finally block may follow it.
  •  Nested try blocks are supported in java


Saturday, September 14, 2013

how to install eclipse IDE

  • Go to http://www.eclipse.org/downloads/ and select the version of eclipse you want to install.
  • I recommend Eclipse IDE for EE developers which has many perspectives like EE , java  etc.
  • Based on your system OS configuration choose 32 bit or 64 bit respectively
  • Click on the windows 32 bit or windows 64 bit (For Windows users) to download.
  • It downloads eclipse as a zip file.
  • Extract the zip file into a folder For Ex:C:\eclipse
  • Go to eclipse folder ,you can see the eclipse application type file.See the snapshot below.



  • Click on it to start the eclipse .
  • Give the workspace location to start 
Happy programming  :)




How to format code in Eclipse

Step 1:
---------
  • Highlight the part of code you wish to format
  • Click Ctrl-Shift-F to format the code

Step 2:
--------
  •  Highlight the part of code you wish to format
  • Go to Source tab beside Edit tab in eclipse and select Format

 Step 1 is just a key board Shortcut:)

Saturday, August 31, 2013

How to run arguments in command line in eclipse


  1. Click on the java program which you want to run 
  2. Go to Run->Run Configurations and select the arguments tab and provide the arguments .
  3. If there are more than one separate the arguments with a space.
  4. Click Apply
  5. Click Run
click on the image to maximise