Wednesday, 31 August 2011

java.lang.NullPointerException

java.lang.NullPointerException


In java many times you face a "java.lang.NullPointerException" exception in running a program. The reason is variable at which the error occurred  does not contain any value or object.


1. If u define any reference variable and don't create any object for that variable 
2. If u define any reference variable  globally but when u create the object then again define it

ex.  JButton btn; /* defined globally */

     JButton btn=new JButton(); /* on the time of creating the object */

This  will give an "java.lang.NullPointerException" when u run the program or pass any event on this button.

solution :- 
1.  btn= new JButton  /* on the time of creating the object */
2. When u don't know then check that for your "object==null" if this is true then initialize object with some value

Monday, 1 August 2011

Use wamp and MySql in win 7 simultaneously

In win7 there is a problem in using wamp and MySql at the same time due to using the same port no. 3306 by the both  wamp and MySql. So for resolving this problem change the port no. of MySql during installation (ex. 3307). Now you can use both at same time. If u want to use Mysql as DB in php then change the port no. in file "config.inc.php" .
For windows the directory of this file is "C:\wamp\apps\phpmyadmin2.11.5"








 In the image in second row give the new port no. of your DB.
I hope it can help u.!!