Hi to all!!!! I Am Arpit Vijay Vergiya.
On this Blog i tried to share about Java.
I hope this blog will help you to learn many new things in java.
Keep visiting!!!
Keep sharing

by · No comments:

Age Calculater in java

Hiii Guys i was reading Date and Calendar class in java. With these two classes we can perform on date.Like we can get Date of system.
And we can calculate difference in two Dates.
We can get the year month and date of user given date.
so i got an idea why can not i write source code in which we can calculate age of a person by given his birth date or current date of system.

Here the source code for Age Calculator:-




import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import javax.swing.event.*;
public class AgeCal1 extends JFrame implements ActionListener
{
    JList jdate,jmonth,jyear;
    JPanel jp,jp1,jp2;
    JScrollPane jsp1,jsp2,jsp3;
    JButton jb;
    JMenuBar jmb;
    JMenu file,help;
    JMenuItem exit,aboutUs;   
    public AgeCal1()
    {
      
    setTitle("Age Calculator");
        setSize(400,450);
        setLayout(null);
    getContentPane().setBackground(Color.PINK);
   
        jmb = new JMenuBar();
        file = new JMenu("File");
        file.setMnemonic(KeyEvent.VK_F);
        help = new JMenu("Help");
        help.setMnemonic(KeyEvent.VK_H);
        exit = new JMenuItem("Exit");
        exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,ActionEvent.CTRL_MASK));
        exit.addActionListener(this);
        file.add(exit);
        aboutUs = new JMenuItem("About Us");
        aboutUs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H,ActionEvent.CTRL_MASK));
        aboutUs.addActionListener(this);
        help.add(aboutUs);
        jmb.add(file);
        jmb.add(help);
        setJMenuBar(jmb);
    addWindowListener(new MyWindowListener(this));
        Vector<Integer>date=new Vector<Integer>();
        {
            for(int i=1;i<=31;i++)
            {
                date.add(i);
            }
        }
        jdate = new JList(date);
        jdate.setVisibleRowCount(5);
        jdate.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        Vector<Integer> mon = new Vector<Integer>();
       
            for(int i=1;i<=12;i++)
            {
            mon.add(i);   
            }
       
        jmonth = new JList(mon);
        jmonth.setVisibleRowCount(4);
        jmonth.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        Vector<Integer>year = new Vector<Integer>();
        for(int i=1950;i<2050;i++)
        {
            year.add(i);
        }
        jyear = new JList(year);
       
        jyear.setVisibleRowCount(10);
        jyear.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        jp = new JPanel();
        jp.setBorder(BorderFactory.createTitledBorder("Select date"));
       
        jp1=new JPanel();
        jp1.setBorder(BorderFactory.createTitledBorder("Select Month"));
       
        jp2 = new JPanel();
        jp2.setBorder(BorderFactory.createTitledBorder("Select Year"));
        jsp1 = new JScrollPane(jdate);
        jsp2 = new JScrollPane(jmonth);
        jsp3 = new JScrollPane(jyear);
       
        jp.add(jsp1);
        jp.setBackground(Color.orange);
        jp1.add(jsp2);
        jp2.add(jsp3);
        jp.setBounds(10,100,100,200);
        jp1.setBounds(130,100,100,150);
        jp2.setBounds(250,100,100,220);
        add(jp);
        add(jp1);
        add(jp2);
        jb = new JButton("Calculate");
        jb.setBounds(100,350,100,40);
        add(jb);
        jb.addActionListener(this);
        setVisible(true);
       
    }
    @Override
    public void actionPerformed(ActionEvent ae)
    {
        if(ae.getSource()==jb)
        {
        try
        {

    int userDate = (Integer)jdate.getSelectedValue();
   
    int userMonth = (Integer)jmonth.getSelectedValue();
   
    int userYear = (Integer)jyear.getSelectedValue();

    Calendar bday = Calendar.getInstance();
    bday.set(userYear,userMonth,userDate);
    Calendar today = Calendar.getInstance();
   
    if((today.after(bday)))
    {
        int curDate = today.get(Calendar.DATE);
        int curMonth = today.get(Calendar.MONTH);
        int curYear = today.get(Calendar.YEAR);
        int day = userDate-curDate;
        if(day>0)
        {
            day=day;
        }
        else
        {
            day=day+(2*(-day));
        }
   
        int month = userMonth-curMonth;
        if(month>0){
        month=month;
        }
        else
        {
            month= month+(2*(-month));
        }
       
        int year = userYear-curYear;
        if(year>0)
        {
            year=year;
        }
        else
        {
            year =year+(2*(-year));
        }
       
        JOptionPane.showMessageDialog(this,"You Are:"+year+" Year"+" "+month+
            "Month"+day+" "+"Days Old..","AgeCal by Arpit",JOptionPane.INFORMATION_MESSAGE);
    }
    else
    {
        JOptionPane.showMessageDialog(this,"Bawali pooch tu to paida nhi hua","AgeCal",JOptionPane.ERROR_MESSAGE);
    }
       
        }
        catch(Exception e)
        {
            if(jdate.getSelectedValue()==null)
    {
        JOptionPane.showMessageDialog(this,"Please select Your Birth Date???","AgeCal v1.0",JOptionPane.ERROR_MESSAGE);
    }
    else if(jmonth.getSelectedValue()==null)
    {
    JOptionPane.showMessageDialog(this,"Please select Your Birth Month???","AgeCal v1.0",JOptionPane.ERROR_MESSAGE);
    }
   
    else    if(jyear.getSelectedValue()==null)
    {
        JOptionPane.showMessageDialog(this,"Please select Your Birth Year????","AgeCal v1.0",JOptionPane.ERROR_MESSAGE);
    }
   
   
        }
       
        }
        if(ae.getSource()==exit)
        {
            Sysetm.exit(0);
        }
        if(ae.getSource()==aboutUs)
        {
            JOptionPane.showMessageDialog(this,"Developed By Arpit Vijay"+"\n"+"Contact:-Vijayarpit.vijay@gmail.com","Agecal v1.0",JOptionPane.INFORMATION_MESSAGE);
        }
    }
   
    public static void main(String...s)
    {
        new AgeCal1();
    }
}


 class MyWindowListener extends WindowAdapter
 {
     AgeCal1 close;
     public MyWindowListener(AgeCal1 ac)
     {
         close =ac;
     }
     @Override
     public void windowClosing(WindowEvent we)
     {
         int x = JOptionPane.showConfirmDialog(close,"Really do you Want to exit???","AgeCal v1.0",JOptionPane.YES_NO_OPTION);
         if(x==JOptionPane.YES_OPTION)
         {
             close.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         }
         if(x==JOptionPane.NO_OPTION)
         {
             close.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
         }
     }
 }





Thanx Guys Dont forget to share and like.
Soon i am going to upload its .Exe so you can easily Run it on windows
Read More
by · No comments:

Features of java

Features of java 

Java is so much popular because of its features.

These are:-

1. Simple, easy and familiar:  

Java is easy to learn and familiar because java syntax is just like c++.
It is simple because:
a) it does not use header files.
b) eliminated the use of pointer and operator overloading.
- See more at: http://javawithease.com/java-features/#sthash.mMzM5XrM.dpuf

1. Simple, easy and familiar:

Java is easy to learn and familiar because java syntax is just like c.
It is simple because:
a) it does not use header files.
b) eliminated the use of pointer and operator overloading.
 

 2. Platform Independent: 
Write once, run anywhere (WORA).


3.Object-Oriented:

Java is Object oriented throughout language- that mean no coding outside of

class definitions,  including main().

Basic concepts of OOPs are:

  •     Object
  •     Class
  •     Inheritance
  •     Polymorphism
  •     Abstraction
  •     Encapsulation

4. Robust:

 Robust  means inbuilt capabilities to handle errors/exceptions.
 Java is robust because of  following:

1. Built-in Exception handling.

2. Strong type checking i.e. all data must be declared an explicit type.

3. Local variables must be initialized.

4. Automatic garbage collection.

5. First checks the reliability of the code before Execution etc.


5. Secure:  
Java is secure because it provides:

1. access restrictions with the help of access modifiers (public, private etc).

2. byte codes verification – checks classes after loading.

Class loader – confines objects to unique namespaces.

Bytecode Verifier- checks the code fragments for illegal code that can violate access right to objects.

Security manager – determines what resources a class can access such as reading and writing to the local disk.


6. Distributed:

Java provides the network facility. i.e. programs can be access remotely from any machine on the network rather than writing program on the local machine. HTTP and FTP protocols are developed in java.
 

7. Compiled and interpreted:

Java code is translated into byte code after compilation and the byte code is interpreted by JVM (Java Virtual Machine). This two steps process allows for extensive code checking and also increase security.
 

8. Portable:

Means able to be easily carried or moved. Write once, run anywhere (WORA) feature makes it portable.
 

9. Architecture-Neutral:

Java code is translated into byte code after compilation which is independent of  any computer architecture, it needs only JVM (Java Virtual Machine) to execute.
 

10. High performance:

JVM  can execute byte codes (highly optimized) very fast with the help of  Just in time (JIT) compilation technique.
11. Re-usability of code:

Java provides the code reusability With the Help of Inheritance.
 

12. Multithreading:

Java provides multitasking facility with the help of lightweight processes called threads.
 

13. Dynamic:

Java have the capability of linking dynamic new classes, methods and objects.

Read More
by · No comments:

Java Versions, Features and History

 

Java Versions, Features and History

 

JDK Version 1.0

Codenamed Oak and released on January 23, 1996.


JDK Version 1.1

Released on February 19, 1997

New features in JDK 1.1

  • JDBC (Java Database Connectivity)
  • Inner Classes
  • Java Beans
  • RMI (Remote Method Invocation)
  • Reflection (introspection only)


J2SE Version 1.2

Code named Playground and released on December 8, 1998.

New features in J2SE 1.2

  • Collections framework.
  • Java String memory map for constants.
  • Just In Time (JIT) compiler.
  • Jar Signer for signing Java ARchive (JAR) files.
  • Policy Tool for granting access to system resources.
  • Java Foundation Classes (JFC) which consists of Swing 1.0, Drag and Drop, and Java 2D class libraries.
  • Java Plug-in
  • Scrollable result sets, BLOB, CLOB, batch update, user-defined types in JDBC.
  • Audio support in Applets.

J2SE Version 1.3

Code named Kestrel and released on May 8, 2000.

New features in J2SE 1.3

  • Java Sound
  • Jar Indexing
  • A huge list of enhancements in almost all the java area.


J2SE Version 1.4

Code named Merlin and released on February 6, 2002 (first release under JCP).

New features in J2SE 1.4

  • XML Processing
  • Java Print Service
  • Logging API
  • Java Web Start
  • JDBC 3.0 API
  • Assertions
  • Preferences API
  • Chained Exception
  • IPv6 Support
  • Regular Expressions
  • Image I/O API


J2SE Version 5.0

Code named Tiger and released on September 30, 2004.

New features in J2SE 5.0

  • Generics
  • Enhanced for Loop
  • Autoboxing/Unboxing
  • Typesafe Enums
  • Varargs
  • Static Import
  • Metadata (Annotations)
  • Instrumentation



Java Version SE 6

Code named Mustang and released on December 11, 2006.

New features in Java SE 6

  • Scripting Language Support
  • JDBC 4.0 API
  • Java Compiler API
  • Pluggable Annotations
  • Native PKI, Java GSS, Kerberos and LDAP support.
  • Integrated Web Services.
  • Lot more enhancements.

Java Version SE 7

Code named Dolphin and released on July 28, 2011.

New features in Java SE 7

  • Strings in switch Statement
  • Type Inference for Generic Instance Creation
  • Multiple Exception Handling
  • Support for Dynamic Languages
  • Try with Resources
  • Java nio Package
  • Binary Literals, underscore in literals
  • Diamond Syntax
  • Automatic null Handling



Java SE 8

Java 8 was released on 18 March 2014. The code name culture is dropped with Java 8 and so no official code name going forward from Java 8.

New features in Java SE 8

  • Lambda Expressions
  • Pipelines and Streams
  • Date and Time API
  • Default Methods
  • Type Annotations
  • Nashhorn JavaScript Engine
  • Concurrent Accumulators
  • Parallel operations
  • PermGen Error Removed
  • TLS SNI
Read More
by · No comments:

Java History


Green Project


January, 1991

Project named “Green Project” was started. Green project’s goal was to support home consumer devices. Consumer devices to be made intelliegent so they can interact with each other and they can be controlled via a remote. Bill Joy, James Gosling, Mike Sheradin, Patrick Naughton were the key members of the Green Project.

Oak


         February, 1991


James Gosling was the software lead and architect. His initial objective was to find a suitable language for Green Project. He chose C++ and wrote extensions wherever there were gaps. Then the features were not sufficient for the project needs and creating a new language was the next move. He started working on the new language and named it as “Oak”, there was an Oak tree outside his office window.



Hardware Prototype


April, 1991

SPARCstation 10’s architect Ed Frank joins Green project to lead the hardware work. Objective was to develop a hardware prototype and demonstrate the capabilities. The project was code named star-seven (*7). Team members of star 7 project were Craig Forrest, Al Frazier, Ed Frank, James Gosling, Patrick Naughton, Joe Parlang, Jon Payne, Mike Sheridan, Chris Warth.


Interpreter

June, 1991
James Gosling works on Oak interpreter


1992

Java Named

March, 1992

Oak was name of another already existing language and so a new name was chosen and it was Java. It was inspired by coffee.



Star-seven Prototype

September, 1992

Star-seven (*7) working prototype with a GUI was completed and demonstrated. At this time Green project has created a new language, an operating system, a hardware platform and an interface. Below is the demo of PDA like star 7 prototype and demo was given by James Gosling himself.



FirstPerson

November, 1992

Green project was incorporated as a separate entity with a name FirstPerson as a subsidiary of Sun Microsystems.

1993

TV Set-top Box

February, 1993

FirstPerson attempts to bag order from Time-Warner for a TV set-top box interactive system. By this time, green project was not proving successful and Time-Warner order was also lost. From home consumer electronics the focus was shifted to TV and set-top box related platform.

Application Development for Platform

September, 1993

Arthur Van Hoff joins the team to work on application development for the interactive platform.

1994

Liveoak

June, 1994

Even TV interactive market was not fruitful for FirstPerson and it was closed. Employees absorbed into Sun. Liveoak project started, aim was to create an operating system by using Oak.

Web Browser Era

July, 1994

Patrick Naughton creates a web browser and uses Java in it. Liveoak project modified to make Oak for Internet.

HotJava

September, 1994

Naughton and Jonatha Payne starts working on a Java based web browser named HotJava and this project gets wider acceptance from the management and progresses.

Java Compiler

October, 1994

Java compiler was written by Van Hoff using Java, previously it was written in C by James Gosling.

1995

Formal Launch

May, 1995

At SunWorld conference Java and HotJava was formally introduced by Sun.


Netscape Support

June, 1995

In a major breakthrough, Netscape supports Java in its browser.

HotJava

September, 1995

First Java developer conference held by Sun at New York.

Oracle Support

October, 1995

Oracle includes a Java compatible browser in its launch of WWW WebSystem.

Microsoft Support

December, 1995

In a first signal for wider industry acceptance, Microsoft supports Java in IE.

 

1996

1.0

January, 1996

JDK 1.0 released.

1997

1.1

February, 1997

JDK 1.1 released. Key features were JDBC, RMI, Inner Classes.

1998

1.2

December, 1998

JDK 1.2 code named Playgroud released. This version is mostly called Java 2 and was the most popular release which witnessed major conversions. Major features were collections framework, JIT compiler, policy tool, Java foundation classes, Java 2D class libraries, major enhancement in JDBC.

2000

1.3

May, 2000

JDK 1.3 code named Kestrel released.

2002

1.4

February, 2002

J2SE 1.4 code named Merlin released. Major features were XML Processing, Java Print, Logging, JDBC 3.0, Assertions, Regular Expressions

 


 

2004

 

5.0

September, 2004

J2SE 5.0 code named Tiger released. Major features were Generics, Autoboxing, Annotations, Instrumentation.

2006

Java/Jdk (Half) Open Sourced

November, 2006

Java was announced to be open source and it was controversial. The way the license was designed contradicted the general open source term. May be we should call it half-sourced.

6.0

December, 2006

Java SE 6 code named Mustang released. Major features were Scripting Language Support, JDBC 4.0, Java Compiler API, Integrated Web Services.

2010

Oracle Buys Sun

January, 2010

Oracle buys Sun and its products. Now Java is in the hands of Oracle.

No Support for Java in Future – Apple

October, 2010

Steve Jobs says, Apple will not support Java in future.

2011

7.0

July, 2011

Java SE 7 code named Dolphin released. This release was done after 5 long years and only this release has taken this much duration. Major features were dynamic language support, Java nio Package, multiple exception handling, try with resources and lots of minor enhancements.

2014

8

18 March, 2014

Java SE 8 was released. This is one of the major release in Java in its history. Major features were Lambda Expressions, Pipelines and Streams, Date and Time API , Default Methods, Type Annotations, Nashhorn JavaScript Engine, Concurrent Accumulators, Parallel operations, PermGen Space Removed, TLS SNI.





 
Read More
by · No comments:

Programming language overview

Programming language overview

As we are going to start learning Java, which is a programming language. So, let us have a brief look at programming language first.

What is language?
A way of communication is known as language. e.g. Hindi, English etc.

What is a Program?
A set of instructions which is used to perform a specific task.

What is a Programming Language?  
An artificial language used to write programs which can be translated into machine language and executed by computer with the help of some special software.
 

What is a Platform?  
Dictionary meaning: A raised level surface on which things can stand.
In programming: Hardware or software on which a program can execute/run.e.g. – c, c++, Java etc.

Programming language overview

As we are going to start learning Java, which is a programming language. So, let us have a brief look at programming language first.

What is language?

A way of communication is known as language. e.g. Hindi, English etc.

What is a Program?

A set of instructions which is used to perform a specific task.

What is a Programming Language?   

An artificial language used to write programs which can be translated into machine language and executed by computer with the help of some special software.

What is a Platform?   

Dictionary meaning: A raised level surface on which things can stand.
In programming: Hardware or software on which a program can execute/run.
e.g. – c, c++, Java etc.
- See more at: http://javawithease.com/programing-language-overview/#sthash.asmxOycF.dpuf
Read More
by · 2 comments:

Introduction to programing language

INTRODUCTION TO PROGRAMING LANGUAGE

  • Computer program is set of instruction that guide a computer to execute a particular task.

  • It is like a recipe for a cook of particular dish . 
  • The recipe contains a list of ingredients called the data or variable and a list of steps that guide the computer what to do with the data. 
  •  So programming is the technique of making a computer to perform something you want to do.
  • Programming or coding is a language that is used byoperating system to perform the task.
  •  We know computer understand binary language that is in0 and 1s form.
  •  It is difficult to understand by human so we use a intermediary language instead of binary language.User write code in language that is made in binary form by third party called compiler and interpreter. 
  • There are many language  fortran c c++ java basic c#

Read More