Jul 31, 2009

Installing php:-
  • Download the zip archive of php from this site.
  • Extract the archive to a c:\php or any name that you like but in the entire explanation c:\php is assumed to be the path where php is installed so replace it with the path to your directory in case you choose to install it in another directory .
  • Rename the php-ini-dist to php.ini because it is the configuration file for php.
  • This completes the basic install and now you can change the configuration parameters in the php.ini like the timezone, displaying errors etc.
Configuring apache web server(almost all people use it):-
  • Then you will have to configure apache web server and that's the tricky part because there are compatibility issues between the apache web server version and the php installation.
  • If you have the php version 5.2.10 then you can configure it for apache web server 2.0.x but the php version 5.3.0 comes with support only for the apache web server 2.2 or greater so you should check the version of apache that you have before downloading php or vice versa.
  • Configuring Apache 2.0.x :-

    • If you have apache 2.0.x then you should download php version lower than 5.30 as it only supports the apache web server 2.2.x
    • Open the apache configuration file httpd.conf and search for "LoadModule" and after the last LoadModule directives just copy and past the following code.

      #php5 module for apache 2.0.x web server LoadModule php5_module "c:/php/php5apache2.dll" #Tell apache web server to recognize the .php extension AddType application/x-httpd-php .php #The php.ini directory assuming it to be the same as c:/php PHPIniDir "c:/php" #end of php5 module

    • Note that we are loading php as a module into the apache web server but you can also load it as a cgi binary. Also note that the dll that was loaded is php5apache2.dll which supports apache 2.0 web server.
  • Configuring Apache 2.2.x :-
    • The steps remain the same but in this case you have the option to download the php 5.3.0 version but lower versions of php also support the apache 2.2.x web server because they contain the php5apache2_2.dll required for the apache 2.2.x server.
    • Just copy and paste the following code at the end of LoadModule directives in the httpd.conf file and i am assuming the installation directory of php is c:\php.

      #php5 module for apache 2.2.x web server LoadModule php5_module "c:/php/php5apache2_2.dll" #Tell apache web server to recognize the .php extension AddType application/x-httpd-php .php #The php.ini directory assuming it to be the same as c:/php PHPIniDir "c:/php" #end of php5 module

    • In this case note that only change is in the LoadModule directive which loads the php5apache2_2.dll which is loaded by the apache 2.2.x web server.

  • Save the http.conf file, restart the apache web server and create a simple test script and place it in the apache htdocs directory. In the test script type and save it as test.php in the apache htdocs directory. Open the browser and type http://localhost/test.php, the installation if successful will show the page containing details about php installation and apache web server.

Activating mysql support for php:-
  • Open the installation directory of php i.e c:\php and then open the php.ini file and search for ;extension=php_mysqli.dll and remove the semicolon in front of it if you have mysql version 4.1 or greater because the mysqli(improved) dll file is for mysql version 4.1 or greater but if you have an older version (although it is highly unlikely) then remove the semicolon from the line that says ;extension=php_mysql.dll .
  • Open the ext directory under the directory where php is installed and if your mysql version is 4.1 or newer then copy and paste the php_mysqli.dll file from it to the main directory i.e directly under the c:\php directory or else copy and paste the file php_mysql.dll.
  • Note that there should also be a libmysql.dll file directly under the main directory,if not then copy and paste that file from the directory similar to the "C:\Program Files\MySQL\MySQL Server 5.0\bin" directory.
  • Now you have to set the path variable by appending c:\php directory path into it so that php can find the 2 above mentioned dlls required for mysql support. To see how to set the path variable see this link.
  • Reboot the pc and start the apache webserver, open browser and type the url to the file we created earlier i.e http://localhost/test.php and if everything goes fine you should see the output similar to the image shown below. This completes the installation of mysql support for php.

Posted on Friday, July 31, 2009 by Ramandeep Singh Nanda

Jul 23, 2009

The dynamic dns service can be used by any person with a non-static ip address to host a website on pc. Non- static ip address means that a person who is using services of an isp and so generally every time he resets his router or modem a new ip address is assigned, so the binding of a domain name to the ip address just cannot happen. The dynamic dns service can be used for this purpose to bind the non-static ip-address to a domain name by constantly updating the ip-address with the domain name provider thus a normal user can host his/her website on pc.

To get the dynamic-dns service up and running for no cost, follow these steps:-
  • Register yourself at this site: http://www.dyndns.com/

  • Get a free or paid dynamic domain name registered with the site.

  • Download and install the tool dynamic dns updater from this link.

  • Launch the tool and open the groups tab, then click on the add button, choose a name for the group, enter the user-name and password for the account that you had earlier established with the site (dyndns.com) and finally click on the download button.

  • After clicking on the download button it will download the details of the domains that have been registered for that user account after which it will update the domain name with your ip-address.

  • If you want to host your website on your own pc and want complete configuration for it then check the following link, where i have explained all the topics like configuring modem, apache, php, etc on your pc.

    Host Website on Pc

Posted on Thursday, July 23, 2009 by Ramandeep Singh Nanda

Jul 21, 2009

The first thing that you should know is that Timer class is available both in java.util and javax.swing packages and they both are different from each other.

I will be discussing code example about the Timer class in javax.Swing package which you can use to make a countdown timer, JprogressBar or do other operations.

Below is the code example and then the explanation follows:-
import java.awt.event.*;
import javax.swing.Timer;
* @author  morph
public class timer_Example extends javax.swing.JFrame implements ActionListener {
Timer timer=null;
javax.swing.JLabel label=null;
static int counter=0;
/** Creates new form timer_Example */

public timer_Example(){
//your code goes here
label=new javax.swing.JLabel("The time is 0 seconds");
timer=new Timer(1000,this);/*create a timer that generates an event after 1 second and pass it the frame object which handles the action event by implementing the ActionListener interface*/

public void actionPerformed(ActionEvent e){
javax.swing.SwingUtilities.invokeLater(new updateCount());

public class updateCount implements Runnable{
public void run(){
counter=counter+1;//update the counter value
label.setText("the time is "+counter+" seconds");
//your JProgressBar code can go here
//or any other code that you may like
public static void main(String args[]) {

timer_Example form=new timer_Example();


The code is pretty basic but this code can be used to perform various tasks. In the code we initialize the counter to 0 and then create the timer object by calling its constructor and passing it 2 arguments the time in milliseconds after which the timer shall generate an event (timer generates an ActionEvent) and second parameter is an event handler for the action event which in this case is the form object itself.

The actionPerformed function just simply checks whether the count has reached 100 or not and if it has it stops the timer. Otherwise it creates a new runnable object of a nested class updateCount which updates the count value and displays the count value through the JLabel. Here you can do other things like updating the JProgressBar or any other event that you may wish to implement. I have used SwingUtilities.invokeLater() function because it is always recommended that you should place the call to some other class on an event queue and not directly call the class.

I have used a similar concept to develop a simple application in java that performs various operations like Shutdown, Hibernate, Standby, lock etc but in that case the counter is countdown counter. You can also create beautiful application launcher windows with changing backgrounds and updating progress bar with it.

Posted on Tuesday, July 21, 2009 by Ramandeep Singh Nanda

Jul 20, 2009

In case you change the password for root account using phpMyAdmin and then try to login into mysql database using phpmyadmin you will receive a log in error and you won't be able to login, this happens because phpmyadmin has no way of knowing what's the root password that you have set.

The phpmyadmin uses it's config.inc.php file for storing mysql user related information and that is where you should enter the root password so that on next log in it can successfully log in to the mysql database.

The solutions to update the password are explained below:-

  1. For Wamp Server:- If you have installed wamp server then follow these instructions
    • Open the apps directory under the directory of wamp server. i.e /wamp/apps
    • Now open the phpmyadmin directory and then open the config.inc.php file
    • Navigate to the line that says "$cfg['Servers'][$i]['password'] = 'xxxx '" and replace the xxxx with the password for the root user and save changes.
    • Now log into the mysql database using phpmyadmin and your login will be successful

  2. For Standalone installation:- In case you have installed phpmyadmin as a standalone version then just navigate to the directory of phpmyadmin and then you can follow the aforementioned solution steps.

Posted on Monday, July 20, 2009 by Ramandeep Singh Nanda

Jul 6, 2009

Problem:-You encounter this error while executing your jar file then it is likely due to missing library files that your jar file needs to run.


For applications made using NetBeans Ide:-
  • Netbeans while making your jar file adds the classpath of the libraries needed for your application to the manifest.mf file and creates the folder lib in the dist folder containing the jar files that your application needs to execute.

  • If you copy and paste just the jar file and try to execute it it will raise an error, so instead of just copying the jar file copy the entire dist folder and then execute the jar. It will work.
For applications made without the Ide:-
  • To add the path of class libraries that are missing just create a plaint text file and then add the class path of the libraries to it. for example if you are getting error for the missing class file org.apache.tools.bzip2.jar located under the xyz directory then you should add the variable as it is shown Class-Path: xyz/org.apache.tools.bzip2.jar and save the text file. Then you should execute the following command.

    jar cfm "Your jar File" "The text file you edited" "the files to add into the jar"

  • Now run the application using the command "java -jar application_name.jar" and it should work fine.
In case you still face problems regarding this issue post your problem and i'll solve it.

Posted on Monday, July 06, 2009 by Ramandeep Singh Nanda