Skip to main content


Showing posts from April, 2010

TCP dump

tcp dump enables us to capture the packets over a network.
But there might be a problem when you run this on localhost.
Like you are running a socket program, and both server and client residdes in localhost only, then it will not work.

The reason for it is:
" It's not reaching the Network Card (NIC) actually when it's in localhost."

This problem has not been reported anywhere. So, always try this thing on two different machines, may be in a LAN. B'coz the request will never reach the card and will not filter request for a particular port.

socket programming in j2me

Well, I found the code for client side everytime but i am not able to find a code working on the server end. So, I ma posting a working code:


public class mpp_usr {

public static void main ( String args[])throws IOException
Socket sock = null;
String str =null;
InputStream in;
byte b[] = new byte[1024];

ServerSocket ss = new ServerSocket(9000);

sock = ss.accept();
in = sock.getInputStream();

DataInputStream din = new DataInputStream(in);

int len;
while((len = > 0) {
String req = new String(b,0,len);

catch(IOException ioe)


if your gnome do or also called dorkey not working.
Go to terminal-> ps -A
it will show all the processes.
kill the process named gnome-do by "kill -9 pro_number"
kill one by one all it's processes, at one instance it'll appear.

If it still doesn't come, then call in terminal
"gnome-do &"
and press ctrl+c
and exit.

Your gnome-do is back.

jdbc mysql cofiguration for eclipse

There might be problem even after installing everything and doing all the coding of jdbc in ubuntu.
So, the solution is :
just download a mysql-connector.jar file
and make your eclipse to point to it.
for this:
right click on project->properties->libraries
here you should see that mysql connector jar.
so, add it by clicking on "add external jar"

Now, the project will run sound.

use of

The method is a factory for connections. You do not use the new operator to instantiate connections. This is a smart mechanism, which keeps the static footprint small when the platform does not include implementations for specific connections. The method throws ConnectionNotFoundException if the desired protocol handler is not available.

store from arraylist into hashtable

import java.util.*;

public class ArraytoHash{
public static void main(String[] args) throws IOException{

String key;
String value;
ArrayList al1 =new ArrayList();
ArrayList al2 = new ArrayList();

System.out.println("Enter key for the hash table : ");
al1 = create();

System.out.println("\n"+"Enter value for the key : ");
al2 = create();

Object ia1[] = al1.toArray();
Object ia2[] = al2.toArray();

Hashtable hashTable = new Hashtable();

for(int i = 0; i < al1.size(); i++)
key = (ia1[i]).toString();
value = String.valueOf(ia2[i]);

hashTable.put(Integer.parseInt(key), value.toString());


Map map = new TreeMap(hashTable);


public static ArrayList create ()
ArrayList al = new ArrayList();
BufferedReader in = new BufferedReader(new InputStreamReader(;
System.out.print("How many elements you want to enter to the hash table : ");

pdf to word

To convert pdf to word, we have a solution to install kword
it's just of 6.5 MB

in terminal, type:

sudo apt-get install kword

and open the pdf doc and just save it as doc.

beginning eclipse

It's very easy to start working on eclipse.
This is the best tutorial i found to guide,
how to start:

and to open an existing project.
go to new-> java project-> same name as of your existing project ->create from existing ( radio button).

point to the location where it's located-> next->finish.

if you have an ant file, better to open it with ant file.
go for new->other->java
->java project from existing using ant->browse the file and just give the project name and finish.

Your project is ready but before that you'll need to install ant in your system and set it's environment variable.

how to run j2me

just download netbeans latest version from :
netbeans have all the stuffs bundled into it, all the toolkits as well as emulator.
No need to install anything after that.

How to run a project of J2me in netbeans:
This is the best tutorial to know how to run it:

database dump and restoration

To create dump of a database, type the following command:



run MySql administrator -> Restore -> open file (back up) -> Restore.
Fill in the required options.

You can also change/assign the username and password from administrator itself.

It's a bit difficult to do it in ubuntu.
Well, here we go for restoration in ubuntu:

1) open terminal
2) mysql -u username -p
3) create database db_name;
4) change db_name;

close this terminal

5) open a new terminal
6) sudo -u username -p database_name < db_file.dmp;

and we are done with restoration
we can check it by opening a new terminal.

build an xml file

go to ;
run -> cmd
go to the location where your xml file is stored.
then type "ant".

before that download ant in your system.
So, download it and path needs to be set in environment variables for ant to run.

configuration for JDBC

Go to:
administrative tools-> ODBC-> User DSN -> Add
to which you want to connect, select an option like MySql ODBC driver.

Data Source name: name of db.
server: localhost
user: root

click on test. It'll notify if the connection is established or not.


sample code for JDBC:

class connect
ResultSet rs;
Statement stmt;

Connection con=DriverManager.getConnection("jdbc:odbc:temp",username,password);

String query;
ResultSet rs = stmt.executeQuery(query);

in query always append "+". e.g.:
"insert into debit values ("+mob_no+","+amount+")"

which ports are open

To check which ports are open in your system, we use "netstat".


go for: c:\windows\system32\netsat -a

NETSTAT [-a] [-b] [-e] [-n] [-o] [-p proto] [-r] [-s] [-v] [interval]
-a Displays all connections and listening ports.
-b Displays the executable involved in creating each connection or
listening port. In some cases well-known executables host
multiple independent components, and in these cases the
sequence of components involved in creating the connection
or listening port is displayed. In this case the executable
name is in [] at the bottom, on top is the component it called,
and so forth until TCP/IP was reached. Note that this option
can be time-consuming and will fail unless you have sufficient
-e Displays Ethernet statistics. This may be combined with the -s
-n …

configurations required to run a project in tomcat

How To Store The Application:
-create a folder of your project in webapps.
-inside that folder create a folder WEB-INf.
-inside WEB-INF create 2 more folders namely, classes and lib.
-Make a web.xml in WEB-INf.

To run your project, you need to configure the xml file ,i.e., web.xml.
where you'll store, say, the servlet name and the url pattern which you'll use to open it in your browser.
classes folder will contain the compiled files of your java program (.class).

go to browser and type: http://localhost:8080/app-folder/url-pattern
give localhost or (IP of the connected system)

on running start tomcat manager but it'll ask for username and password. So, configure a file:
modify/add username and password for manager.

Now, start the tomcat from terminal by start.bat and go for the URL in the browser. After the completion just type shutdown.bat in command prompt.

Note: while installing this, you need to kill all the processes related to tomcat.
Note: Netbean…

how to run apache tomcat server

first download the setup from :
don't download the .msi, rather download a zip file.

Now, extract it wherever you want.
now, make a folder of your project and store it in webapps folder in apache.

open command prompt->cmd
now go to location in apache where bin lies.

your tomcat is started.

J2EE inital configuration

For the set up of J2EE, there are various problems one may face initially.
The configurations and system's environment variable setting needs to be done.
Windows users don't forget to do :


C:\> SET MYVAR=widget


Use the System Variables dialog. To reach this dialog, right-click the My Computer icon, select the Properties menu item, and select the Environment tab.Enter the variable name and its value, and click the Set button.
So, we need to set up the paths of bin of j2se, bin of j2ee and directory of j2ee where it is installed.

You can follow the links:

People are welcome to discuss their doubts.


The stuff is more likely to be about J2ME.
J2ME empowers you develop very cool features for your mobile.
All you need is a java enabled mobile.
Well, we can discuss all the J2ME related problems here.

Those who have heard of it first time or want to start working on it..
Here's the hint for them :
Go for Hello World example in j2me. So, here's an example for it:

I would refer the books who really want to go for some of the cool reading stuff:
1) Beginning J2ME novice to professional, Apress
2) The Complete Reference, James Keogh
Though, I am not an expert in it but still we can put up our knowledge and experience to make " a mobile, a world in itself".. :D