Posts

Showing posts from May, 2009

Java System.out.println() explained in OOP

Hi, all Java programmers must have used the " System.out.println() " method many times during their programming careers. It is used even in the HelloWorld Java code. The most interesting part of it is that how it complies with the OOP (Object Oriented Programming) concepts. Many of us have used it, and are using it over and over again without any consideration on how this fits on with the OOP concepts. In this post I expect to give my clarification on how it is implemented. Obviously " System " is a public class. And at first, it seems as if we were accessing a static method of the " System " class by calling System.out . But, if it was a method, we would basically call a method in the following manner. System.out(); where we would be using parenthesis, and we do not use it in this case. Hence the concept regarding a static method call of a " System " class fails. We can access class variables by calling . . Given that the class variables ar

Send J2ME Mail

Hi, most of you may have wondered how to send mail using J2Me. With the support of J2ME and J2SE, it becomes simple. If you have developed Standalone/Desktop mail sending applications before, this may be even easier. If not please reffer to the following article before http://ruchiram4.blogspot.com/2008/12/sending-mail-using-java.html I assume that you are familiar with J2ME basics (Sun Wireless Toolkit, Midlets) and have the basic knowledge in deploying an application in Tomcat Server. The architecture for sending J2ME is slightly restricted. You cannot have your own SMTP Server. So, the J2ME application works by first establishing a connecting with a website/service and passing the relevant values(Eg: Message Subject, To Address, Message Text) to it. In my case, I used Tomcat and created a Servlet to handle such requests. So, we have two applications running seperately. 1. The J2ME Mobile application 2. The J2SE Server Application On receiving the request, the Servlet would process a

J2ME Split String code segment

Most of you who are used to the split() functionality may miss it a lot when moving on to J2ME. So, here is a code segment which I had used to acchive similar functionality using J2ME methods. public String[] split(String str, String delimiter){ //Iterate through the text to get the count of occurences //This is done since we do not know how many times the //delimitter occurs in the given string //--------------------------------------------------// int delimiterCount=0; int index; String tmpStr=str; String[] splittedList; while((index=tmpStr.indexOf(delimiter))!=-1){ tmpStr=tmpStr.substring(index+delimiter.length()); delimiterCount++; } splittedList=new String[delimiterCount]; /*-----------------------------------------------*/ /*-----------------------------------------------*/ //

Connect MySQL with NetBeans

Image
A very common problem which recurrs through software development is on how to connect to MySQL Database server using NetBeans IDE. In this post, I intend to present a very clear description on how to do so. I have used NetBeans 6.1 with MySQL DB Server. But connecting with other versions of the IDE would be similar. 1. Open your IDE and click on the "Services" Tab as shown. If it is not shown, click on Windows->Services to display it. You can see the Driver for MySQL is already added to NetBeans. Otherwise, right click on "Drivers" and click 'New Driver'. Then show the location of the New Driver. Right Click on MySQL and Click "Connect Using". Then you should get the following dialog. 2. This dialog requests the relevant configuration details of the Database server. You can observe a TextBox displaying the "Database URL". This is the connection String used to connect to the database. There are three main fields which you must supply a)

How to Browse Folders using Dot NET

Image
Most of you may have come up with scenarios where you wish to let the user browse for a specific folder or file. This is most commonly occured when you are requested to open a specific file in Word or Power Point. I would be using Visual Studio 2005 and DOT NET Framework 2.0 DOT NET 2.0 Framework supports several useful dialogs. In this, we will use the "FolderBrowseDialog" class for the example. It can be very easily found in the "ToolBox" under "Dialogs" category. Simply drag and drop one on to your Form. Add a Button also for the demo. Then, double click on the Search Button and it would take you to the Click Event of the Button. Inside that, place the following LOC. DialogResult result; result = folderBrowserDialog1.ShowDialog(); if (result == DialogResult.OK) { MessageBox.Show("Selected Path :" +folderBrowserDialog1.SelectedPath); javascript:void(0) } Lets anal