Friday, 13 July 2012

Varargs in java (Passing variable no of arguments in java program)

After J2SE 5.0 java supports passing of variable arguments in a method that u don't need to fix the no of arguments at the time of defining the method .
Compiler automatically converts the arguments in the form of array so u can access all the arguments at run time.





Example:-


public class Varargs
{

    public static void main(String[] args)
    {

        Varargs var = new Varargs();

        var.show("Ankit", "Singh", "Katiyar");

        var.show("facebook.com\"", "ankitkatiyar91");

    }

    public void show(String... arg)

    {

        for (int i = 0; i < arg.length; i++)

        {

            System.out.println(arg[i]);

        }

    }

}



Note:- it   works only it version J2SE 5.0 or above.

You can use any data type for variable arguments.

Example:-

package javaTest;

public class Varargs {

public static void main(String[] args) {
// TODO Auto-generated method stub
Varargs var=new Varargs();
var.show(1,2,3);
var.show(9,7);

}
public void show(int... arg)
{
for(int i=0;i<arg.length;i++) 
{
System.out.println(arg[i]);
}
}

}

Rules :-
* For any method it must be the last argument.

Friday, 4 May 2012

External garbage collection in java

In java garbage collection is internally implemented. For it JVM(Java Virtual Machine) uses a Class
java.lang.Runtime  .

The JVM's heap stores all objects created by an executing Java program. Objects are created by Java's "new" operator, and memory for new objects is allocated on the heap at run time. Garbage collection is the process of automatically freeing objects that are no longer referenced by the program. This frees the programmer from having to keep track of when to free allocated memory, thereby preventing many potential bugs and headaches.


You can also externally  set the max heap size for your JVM by the VM command
java -Xms .

If u   want to implement garbage collection in your program u can use the method of Runtime  class there is a native method defined in java that is used to call a garbage collector.


Runtime r = Runtime.getRuntime();
r.gc();

Tuesday, 10 April 2012

Microsoft Windows 7 64bit ODBC type 1 driver DSN problem



In windows7 if you are using type 1 driver for your JDBC the u face a problem of creating DSN from control panel administrative tool then try this location file
this will allow you to create a DSN as u desire.
I tried this working.

c:\windows\syswow64\odbcad32.exe

Enjoy :(

Friday, 6 April 2012

SPEEDUP YOUR COMPUTER BY CLEANING YOUR RAM USING NOTEPAD


Does your computer boot slowly or shuts down slowly? Then this tutorial is for you.. One of the major problem of computer coming up slow is
1. UNUSED JUNK IN RAM.
2. TOO MUCH PROGRAM ON THE COMPUTER DESKTOP( ICONS,)
4. VIRUSES ETC

CLEAN UP YOUR RAM
STEPS:-----------------------------
1- Open Notepad
2- Copy and paste these codes into notepad FreeMem=Space(64000000) .
3- Now Save it as CleanRAM.vbs.
NB:- IN THE SAVE AS TYPE DROP DOWN MENU, CHOOSE ALL FILES
4-Now Open it and your RAM will be free from unused junks!

Friday, 3 February 2012

Jar Files are not working properly


Problem - Jar (.jar) files are not working as it should be they are opening in Nokia Pc Suite or in other program.
Solution – Easiest way to solve this problem
1.    Uninstall the program in which they are opening.
2.    Now change the open with setting of .jar file
a.     Set it to Java(TM) SE Platform.
b.    Mark Always open in this program
3.    Now again install the program
4.    This time jar files will work properly.

Monday, 19 December 2011

FIXING SSL FOR WAMP

ERROR:
There was a problem opening a secure connection to Google. This is what went wrong:


Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (1)


Recently I had to fix a bug/oversight in the WAMP install that prevented ssl from being a registered stream socket transport, it turns out there are quite a lot of requests for help on this subject out there but few or no answers. I stumbled into this problem when I tried to setup SSL encrypted email by way of google’s SMTP servers and if by putting my solution here I help just one person then it is worth it.


The common error message that you will get when trying to do an SSL transport on a default WAMP install is: “Unable to find the socket transport “ssl” – did you forget to enable it when you configured PHP?”


The solution it turns out is quite obvious, but maybe not so much when you are sleep deprived and multitasking, what you need to do is:


    1. Stop the Server
    3. Edit the C:\wamp\bin\apache\apache2.2.8\bin\php.ini and uncomment “;extension=php_openssl.dll” (remove the semicolon at the start of the line)
    4.Start the Apache service


If you now check your phpinfo() page you will see Registered Stream Socket Transports: tcp, udp, ssl, sslv3, sslv2, tls and everything will now be working.
After updating to the latest version of xampp (1.7.7) it appears the problem still exists, the php.ini file to edit now exists in the ../xampp/php directory, you need to add “extension=php_openssl.dll” in there. No other steps are required (apart from the obvious restart of apache).

Saturday, 3 December 2011

Android Plug In For Eclipse IDE

For starting with android on your MyEclipse IDE  you have to follow Small Steps:-

Step 1- Download android sdk from the link "http://developer.android.com/sdk/index.html" and extract it   into the path your want prefer to "C:\" or "C:\Program Files\Android" .


Step 2- Now Open your eclipse IDE and go to "Help -> Install new software" then give the site "https://dl-ssl.google.com/android/eclipse/" to download plug in from the site download from site and then give the archive "http://dl.google.com/android/ADT-15.0.1.zip" to install it and mark on install updates.

Step 3- Now open sdk from eclipse or directly and install the API and Virtual devices .

Step 4- Now keep updating your sdk and plugins

Step 5- Make your android project or you can also check for sample programs.

Useful Links :-
http://developer.android.com  
http://code.google.com/android/