Tuesday, December 13, 2011

Finding text from files in Subdirectories

We can use grep command to find a string in files existed in subdirectories also.

Syntax: grep -Rl <string> <directory path>

Ex: grep -Rl "text" /var/tmp

The above command greps the string "text" from all the files of the path /var/tmp and their subdirecoties, and prints the list of files that contains the string "text".

Visit articles page of the website learningmela.com

Thursday, December 8, 2011

SOAP Errors with Service Center

Hi all,

Click here to download the document.

In this document, tried to explain different types of errors we face while connecting to Service Center using SOAP tool. We can also get these errors while using the tool to connect any other web services.

Visit articles page of the website learningmela.com

Monday, November 14, 2011

Using Properties in Java

Properties file is being used commonly in every project to get external or supported parameters like configurations, urls, port numbers and ids etc. We can handle these files using file stream APIs like FileInputStream, FileOutputStream etc, provided in java by treating these files as normal text files. But another way is also there to handle the property files, which is the best and efficient way to handle these by using the API java.util.Properties.

The class Properties has few methods on which the below are very important and most useful.

  1. load(InputStream in): To load the external properties file
  2. loadFromXML(InputStream in): To load an XML file as a property file
  3. getProperty(String key): To read value of a property key from the property file
  4. getProperty(String key,String defaultValue): To read value of a property key from the property file. If the key doesn’t exist then it will return the defaultValue.
Let us see an example to understand how to use the Properties class.
Create a properties file which contains keys separated by new line and their corresponding value pairs.
Below is a sample properties file which has three properties “name”, “message.ok” and “message.error”.

message.ok=You are a valid user
message.error=You are not valid user

Let us write a java program to use these properties.
Below is a sample program which reads the property “name” from the property file and if the comparison is true then it will print the value of the property “message.ok” else prints the value of the key “message.error”.
Learning Mela, author: Anand Y

Java code: PropertiesTest.javaimport java.util.Properties;
public PropertiesTest
String propFile="Test.properties";
public static void main(String[] arg)
Properties props = new Properties();

The below statement is to load the property file from the path where the .class file of the above program is existed.

Visit articles page of the website learningmela.com for more details.

Thursday, November 10, 2011

Write Files

WriteFiles is a java tool to integrate several textual files to a single file. In some scenarios like where we need to copy all source code files into a document or a textual file, it is difficult to copy the content of all the files manually. For example, if you take java application where there will be different source files under different packages, it starts from a root directory (package), includes sub directories and their sub directories and so on. Each directory or sub directory may have their individual java classes. If you want to copy all these source files including the sub folders, think how difficult it is to do so. This tool can help you to do the same.

Visit Projects page of learningmela.com for more details and to download the tool.

Wednesday, November 2, 2011


This is a runtime error simply means that the JVM ran out of memory. 

We can choose either of the below two solutions to fix it.

1)      Prevent memory leak: Yes. Preventing memory leak will also improve the performance of the application. A memory leak can be very latent. A memory leak occurs when the application creates more references to objects and never releases them. So the garbage collector will never collect those objects results less free memory will be available, hence not enough free memory is available for the application to function normally. 

2)      Increase the heap size of the JVM.
It can be done by using the VM argument –Xmx 

Syntax: java -Xmx<size> <java class> -d<bit mode>

Where, Size is the size of the memory asking JVM to take
Java class is the program name to which memory is required
Bit mode tells which bit mode of operating system is being used. Either 32 bit or 64 bit 

Ex: java -Xmx1024m MyJavaClass -d32 //It asks JVM for 1024 MB space Java
      java -Xmx2g MyJavaClass –d32       //It asks JVM for 2 GB space Java

Visit articles page of the website learningmela.com for more details.

Sunday, October 30, 2011

Excel To DB

ExcelToDB is a tool developed in Java, is a very useful tool if you want to import data from MS-Excel to data bases MS-Access or Oracle.

Below is the GUI of the tool.

Visit Projects page of learningmela.com for more details and to download the tool.

Saturday, October 29, 2011

Creating a User form in MS-Excel

In this article, we are going to know how to create a user form in MS-Excel using VBA script.

Download the document to see the step-by-step procedure to know how to create a form in MS-Excel using VBA programming.

Visit articles page of the website learningmela.com for more details.

Access to Excel

Here is a small VBA script written in MS-Excel to download the data of a table from MS-Access to the excel sheet, which might useful while preparing status reports or analyzing data.

Visit Projects page of learningmela.com for more details and to download the tool.

Friday, October 28, 2011

Primary Key Vs Unique Key

This post is to share my knowledge on how Unique key is differs from Primary key. As both are enforces uniqueness, why can’t we go for unique key instead of primary key. In this document I tried to give some features of primary key as well as unique key.

Visit articles page of the website learningmela.com to download the document and for more details.