Saturday, March 1, 2014

On The Cloud [AWS]

I was assigned to setting up new server on AWS and i was pretty much excited while i started working on it. Being a java guy, i am having no knowledge of working with servers, but let see:-

Setting up ISPConfig 3:-

Just followed the instruction given on this article. And yeah ISPConfig is installed.

Successfully generated SPF

Now i am stuck with DKIM, i have to set my mail server and i used Postfix for it, but my ClaimAV is real pain in the arse. I have created DKIM key and all other settings but now mail delivery is stopped. :'(

Dammn itt. I had no SWAP on AWS that is why it was failing.
I found out via:-
free -m

I added swap space by help of this link :-

SWAPFILE=/mnt/swapfile.swap
dd if=/dev/zero of=$SWAPFILE bs=1M count=512
mkswap $SWAPFILE
swapon $SWAPFILE


and voila its working......  ^_^

Sunday, September 22, 2013

Java inheritance concept

Interviewers loves to trap candidates in inheritance and overridding concepts. So here is the solution. Just copy the code below and you will understand all about it as soon as you run this code. Let me know in case of any confusion.  ;)

P.S.:- Be careful for the "**".




public class InheritanceConcept {

public InheritanceConcept() {
System.out.println("Inside Polymorphism Constructor");
}

public static void main(String args[]) {

Parent p = new Parent();
Child c = new Child();

Parent pCast = new Child();
// Child cCast = (Child) new Parent(); //Class Cast Exception **Downcasting

p.ParentsMethod(); //inside ParentsMethod
p.OverriddenMethod(); //inside Parent's OverriddenMethod

c.ParentsMethod(); //inside ParentsMethod
c.ChildsMethod(); //inside ChildsMethod
c.OverriddenMethod(); //inside Child's OverriddenMethod

pCast.ParentsMethod(); //inside ParentsMethod
pCast.OverriddenMethod(); //inside Child's OverriddenMethod **Runtime Polymorphism/Dynamic Binding

}
}

class Parent{

Parent(){
System.out.println("Inside Parent's Constructor");
}

void OverriddenMethod(){
System.out.println("inside Parent's OverriddenMethod");
}

void ParentsMethod(){
System.out.println("inside ParentsMethod");
}
}

class Child extends Parent{

Child(){
System.out.println("Inside Child's Constructor");
}

void OverriddenMethod(){
System.out.println("inside Child's OverriddenMethod");
}

void ChildsMethod(){
System.out.println("inside ChildsMethod");
}
}

Tuesday, June 26, 2012

Comparison BetweenTwo Dates


Monday, June 11, 2012

Select Option Ops

<html>
<body>

<select id="slct" onchange="slct();">
  <option value="1">Volvo</option>
  <option value="2">Saab</option>
  <option value="3">Mercedes</option>
  <option value="4">Audi</option>
</select>

<script>
function slct(){

    var selObj = document.getElementById('slct');
    var selIndex = selObj.selectedIndex;

    alert(selIndex);
    alert(selObj.options[selIndex].value);
    alert(selObj.options[selIndex].text);
}
</script>


</body>
</html>

Tuesday, May 22, 2012

Codelets

#Convert String to Date in Java


java.util.Date = java.text.DateFormat.getDateInstance().parse(date String);
or


SimpleDateFormat format = new SimpleDateFormat( "dd.MM.yyyy" );
Date date = format.parse( myString );

Saturday, March 3, 2012

Read File In JAVA


import java.io.*;

class ReadFile{

    public static void main(String args[]) {
        try {

            FileInputStream fstream = new FileInputStream("c:/yash.txt");

            DataInputStream disobj = new DataInputStream(fstream);

            BufferedReader br = new BufferedReader(new InputStreamReader(disobj));

            String frst = br.readLine();
            String scnd = br.readLine();
            if (frst != null) {
                System.out.println(frst);
                System.out.println(scnd);
            }
            else{
                System.out.println("empty");
            }
            disobj.close();

        }
        catch (Exception ex) {
            System.out.println(ex.getMessage());
        }

    }
}

Sunday, February 19, 2012

In The Spring 3.0

Introduction-


To be very honest i am not some die hard geek coder or some sort of JAVA Guru writing some Bible. I am just a beginner who just started learning to work in JAVA but i am trying to note all the points i am covering while learning Spring 3.0. Just hoping, may be it will also help you. Have fun. :-)