Sunday, November 15, 2009

The Most Significant Features of Java Language

The Most Significant Features of Java Language

Author: john wircken

Java is an object-oriented programming language developed by Sun Microsystems in 1990s. Since then, Java has gained enormous popularity as a computer language. Java was chosen as the programming language for network computers. It is a universal front end for enterprise database. Sun Microsystems states that, “Java is a simple, object-oriented, distributed, secure, architecture, robust, multi threaded and dynamic language. The program can be written once, and run anywhere”. One of the most significant advantages of Java is that, it has the ability to move easily from one computer to another. It also has the ability to run the same program on many different operating systems. With such exemplary benefits, Java is a hot favorite among techies and software professionals.

Java has significant advantages compared to other languages. Java language is easy to use and therefore easy to write, compile, debug. Moreover, it is easier to learn when compared to other programming languages. Since Java is object-oriented, it allows you to create modular programs and reusable codes. Platform-independent, Java is a robust language. The language lays more importance on early checking for errors, since Java compilers can detect many problems during the time of execution of an application. Java is multithreaded, since it has the capability for a program to perform several tasks simultaneously within the same program. Java Development has gained a significant position in the industry with programmers and developers finding it easier and more effective than many other languages.

Java applications are designed to be compiled and then interpreted at runtime, unlike the conventional programming languages, which can either compile source code to native code or interpret the source code. The language itself has borrowed the syntax from C and C++. Java considers security as a part of its design. The Java language, its compiler, interpreter, and runtime environment are all developed with security. Writing network programs in Java is similar to sending and receiving data to and from a file.

The Java programming language was developed and re-designed for use on the Internet. In the internet domain, Java’s popularity has increased tremendously, especially on the server side of the Internet. Nowadays, there are a large number of Java experts who strive for the enhancement and improvement of Java development. For beginners who are interested in learning Java, the numerous Java tutorials available online are good to start with. Java tutorials and Java tips are the best resources for learning and improvising in Java.

Java Development experts are trying to enhance their programming skills for writing secure Java applications. In order to write a secure code in Java you need to be aware of various things such as data handling techniques, user authentication rules, access controls etc. JavaScript is a scripting language which shares a similar name and has the same syntax, but is in no way related to the core Java language. Few steps are crucial for a secure Java application development. They are logical software design, proper validation, well planed application development and standardized security test. Java has become the language of choice world over for providing effective and sure-fire Internet solutions.

Article Source: http://www.articlesbase.com/programming-articles/the-most-significant-features-of-java-language-295578.html

About the Author:
The article is written by John Wircken. It is mainly based upon Java Development

Sunday, October 11, 2009

Refletion API

Hope that everybody having problems with the reflection API will get some help from this tutorial.

This is what the sun java tutorials say about this API.

Reflection is commonly used by programs which require the ability to examine or modify the runtime behavior of applications running in the Java virtual machine. This is a relatively advanced feature and should be used only by developers who have a strong grasp of the fundamentals of the language. With that caveat in mind, reflection is a powerful technique and can enable applications to perform operations which would otherwise be impossible.

you can get the full sun tutorial Here.

So sun says "This is a relatively advanced feature and should be used only by developers who have a strong grasp of the fundamentals of the language" so i don't know why they added this to CSE syllabus in the third lecture?????.

What to do now we must learn it so i thought to make a simple tutorial so everybody can understand.

Let's start

  • To look into java classes and find out what they are made of we must first be able to catch the class itself to do this there are three ways but we will only need one.
1.the simplest way
Class c=Class.forName("fully-qualified name of a class");

Here the fully qualified name means class with packages for example if we have class "foo" in package "packfoo"
the fully-qualified class name would be "packfoo.foo";.

Then we have to find out the properties of the class like the name of it's super class,modifiers to do this you can use methods given in the Class class(look at all the methods Here).

Here are two methods from the Class class
1.to get the super class-c.getSuperclass()
2.to get the modifiers-c.getModifiers();
there a load of methods in the Class class which you can use similarly
  • Then we have to be able to get properties of methods in the class.
First we must get all the methods in the class to do this there are two methods in the Class class.

1.to get all the public methods and inherited methods-
Method m[ ]=c.getMethods();
Her "Method" is a variable type that can keep objects passed by the "getMethods();" and here we have used a array because this method return a array of "Method's".

2.to get all the other methods like private methods(includes public methodes but does not include inherited methods) -
Method m1[ ]=c.getDeclaredMethods();

Then just like the Class methods the 'Method' class also has a lot of useful methods like. m[0].getName(),m[0].getReturnType()

Now we have to get the variables for this it's same as the methods just two deferent methods to get the values.

1. to get all the public variables and inherited variables-
Field f[]=c.getFields();
Her "Field" is a variable type that can keep objects passed by the "getFields();" and here we have used a array because this method return a array of "Field's".

2.to get all the other variables like private variables(includes public variables but does not include inherited variables) -
Field f1[]=c.getDeclaredFields();

Then again 'Field' class also has a lot of useful methods like f[0].getName(),f[0].getModifiers();


Here is a simple example

The Main class

package javaapplication1;
public class Main {

public static void main(String[] args) {

Inspector insp = new Inspector("javaapplication1.NewClass");
System.out.println(insp);
}

}

The NewClass



package javaapplication1;


public class NewClass extends NewClass1 {
public int i=20;
public String name="supun";
int k;
private int y;
String nothing;
public int edan1(){
return 34;
}
int edan2(){
return 34;
}
private int edan3(){
return 34;
}
}

The NewClass1




package javaapplication1;


public class NewClass1 {
public int superr=21;

public String supermethod(){
return "super";
}
}
The inspector class (this does all the work)






package javaapplication1;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class Inspector {
private Class thisClass;
private Class superClass;
public Inspector (String className) {
try {
System.out.println("Loading class : " + className);

thisClass = Class.forName(className);
System.out.println("Class load successful");

System.out.println("Prointing super class and modifier");
System.out.println(Modifier.toString(thisClass.getModifiers()));
superClass = thisClass.getSuperclass();
System.out.println("Super class : "+ superClass);



Field[] f=thisClass.getFields();
Field[] f1=thisClass.getDeclaredFields();
System.out.println("get public feilds ");
for(Field x:f){
System.out.println("name--"+x.getName());
}
System.out.println("get other feilds ");
for(Field x:f1){
System.out.println("name--"+x.getName());
}


Method[] m1=thisClass.getDeclaredMethods();
Method[] m=thisClass.getMethods();
System.out.println("get public methods ");
for(Method x:m){
System.out.println("name--"+x.getName());
System.out.println("return type--"+x.getReturnType());
}
System.out.println("get other methods ");
for(Method x:m1){
System.out.println("name--"+x.getName());
System.out.println("return type--"+x.getReturnType());
}

} catch (Exception e) {
System.out.println("Error loading ");

}
}
}


Please feel free to comment on the tutorial

Friday, October 9, 2009

Getting Startd with JAVA -1

Now What's JAVA ??

java is one of the best and most used programming languages used these days.The things you can do with java are endless.And it is so vast that you cant just finish learing it.

So lets get started.lets first see what you will be needing to get started
1.first you need a computer(he he he)


2.you need to install some JDK version on your computer
The latest can be downloaded Here


3.A Software to Write programs in

It's realy easy to use one than to type on the notepad and run manualy.If you want to learn from scrap you should use JCreator LE.because it only provides the basic needs you can learn a lot you can get it Here.

If you want to do High level programing use NetBeans IDE You can find the latest version Here .This is not good for basic learning because it does more than half of the coding for you

4.Configuring your pc(this part is not needed if you use NetBeans)
You must set the eniviroment variable to the bin folder do as below

  • Find where the bin folder is an copy it's path.it should be somting like this "C:\Program Files\Java\jdk1.6.0\bin"
  • then go to properties



Click on Enviromentel varables

And click on path go to the end of the existing variable value and put a ";" and paste tha path you
copyed.

5.And the most important HOW TO CODE
Now to get Started with java obviously you need to get some good traning you can find some great tutorials Here. And if you would perfer books to learn theres a lot of books that are good
  1. sams teach yourself java in 21 days
  2. scjp by Kathy Sierra
  3. java how to program
  4. java 2 by Ivor Horton

Tuesday, September 29, 2009

Partisipate In Google Summer Of Code(GSOC)


Hey if you are interested in a open source  programming gsoc is the best event to a go to.It is held every year
And is Done by Google and is a great place to learn how to work in open source  programming  there  are  a lot
of benifites.And if you are new to working in big projects its a great event
 watch this vedio to get a good idea


                               



for more information goto http://code.google.com/soc/

Sunday, September 27, 2009

Watch funny people online


Watch the newest comdey online

Release Date: 2009
Duration: 132min
Category: Comdey , Psychological Drama, Showbiz Comedy


Links-


How to include Google maps in your website

hey google maps is a cool tool you can use in your web sites and its very easy to add it but there is one problem
google has rules for free users that they cannot use it for commercial purpose's but u can use it if you are building for fun.if you realy like it and want it you can by it for commercial use
here is the first few steps to get it done
goto    http://code.google.com/apis/maps/ and there will be a link called Sign up for a Google Maps API key. 
to get this feature you should own a gmail account because you have to sign up using you gmail account
then they will give you a API key that you will use in the code to get the service
<script src="http://maps.google.com/maps?file=api&v=2&sensor=true_or_false&key=[put the API key you got here]"
    type="text/javascript"></script>
    <script type="text/javascript">

    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        map.setUIToDefault();
      }
    }
</script>
The API key is a very long key
And please read the google terms of service before you use it  http://code.google.com/apis/maps/terms.html


Saturday, September 26, 2009

And Image Viewer using Ajax

This is a image viewer made using Ajax its cool no refreshing and realy quick thats the good
of Ajax
var xmlHttp;
function show(i){
document.getElementById("state").value="1";
document.getElementById("num").value=i;
showPics();
}

function showPics()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("Get","getpics",true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
if(xmlHttp.status==200){
var pics=new Array();

var xmlDoc=xmlHttp.responseXML.documentElement;
var links = xmlDoc.getElementsByTagName("picture");
var state= document.getElementById("state").value;
var num = document.getElementById("num").value;

for ( var i = 0; i < 3; ++i )
{
try{
pics[i] = links[i].childNodes[0].nodeValue.toString();



}catch(err){
break;
}

}


if(state=="0"){
for(x in pics){

var l=(++x);



document.getElementById("pic"+l).src="./images/"+pics[--x];
}
}else{

document.getElementById("pict").src="./images/"+pics[--num];
}


}
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

</script>
<input type="hidden" name="name" value="0" id="state"/>
<input type="hidden" name="name" value="" id="num"/>

<pre>
<center><img src="" id="pict" width="344" height="200"/></center>

<%
connection con=new connection();
ResultSet rst=con.getDataP();
rst.last();
int num=rst.getRow();
for(int i=1;i<=num;i++){            out.print("&ltimg src="+""+" width="+"128"+" onclick="+"show("+i+");"+" height="+"133"+" id="+"pic"+i+"<");            }          %>  
You should have a connection class to connect to a database (here i used mysql and the Ide was netbeans) this code should do the job to get data
public ResultSet getDataP(){
ResultSet rst=null;
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/[name of the database]","root","[your mysql password");
Statement stm=con.createStatement();
rst=stm.executeQuery("select * from [name of the table]");
}catch(Exception e){

}
return rst;
}
And for the command xmlHttp.open("Get","getpics",true); to work you should have a servlet that converts the database info to xml format
lets name it getPics.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/xml");
PrintWriter out = response.getWriter();
response.setHeader("Cache-Control","no-cache");
try {

connection con=new connection();
ResultSet rst=con.getDataP();
out.print("<userpic>");
while(rst.next()){

out.print("<picID>"+rst.getString(1)+"</picID>");
out.print("<picture>"+rst.getString(2)+"</picture>");


}
out.print("</userpic>");

}catch(Exception e) {

}
} 


Thursday, September 24, 2009

How to make web based a wordpad using gwt



gwt is one of the best ways to develop user frendly web applications this is my first project done using
gwt i want be able to put the complete code because its too long but i'll put a few useful codes

Creating a menuBar(this goes in the class that extends EntryPoint)
MenuBar menu = new MenuBar();
menu.setAutoOpen(true);
menu.setWidth("500px");
menu.setAnimationEnabled(true);

// Create the file menu
MenuBar fileMenu = new MenuBar(true);
fileMenu.setAnimationEnabled(true);
menu.addItem(new MenuItem(constants.cwMenuBarFileCategory(), fileMenu));
String[] fileOptions = {"New","Open","Save","Save As","Print","Print Preview","Exit"};
for (int i = 0; i <fileOptions.length; i++) {
fileMenu.addItem(fileOptions[i], menuCommand);
fileMenu.addSeparator();
}

// Create the edit menu
MenuBar editMenu = new MenuBar(true);
menu.addItem(new MenuItem(constants.cwMenuBarEditCategory(), editMenu));
String[] editOptions = {"Undo","Cut","Copy","Paste","SelcetAll","Clear"};
for (int i = 0; i <editOptions.length; i++) {
editMenu.addItem(editOptions[i], menuCommand);
}

}

Now menuCommand is were you put the coding for the action when the link is clicked you will have to useone for each here i only used one.first make another class
CommandHere.java

Command menuCommand = new Command() {


public void execute() {
Window.alert("you just clicked it");
}
};

public Command getMenuCommand() {
return menuCommand;
}



Using a dialogBox to insert Bullets into a text area and how to use popups to make it user frendly

Button bullets=new Button();
RichTextArea ta=new RichTextArea();
final DecoratedPopupPanel bulletpop=new DecoratedPopupPanel(true, false);
bulletpop.ensureDebugId("cwBasicPopup-simplePopup");
bulletpop.setWidth("10px");
bullets.addMouseOverHandler(new MouseOverHandler() {

public void onMouseOver(MouseOverEvent event) {
int left = 620;
int top = 55;
bulletpop.setPopupPosition(left, top);

bulletpop.setWidget(new Label("bullets"));
bulletpop.show();
}

});
bullets.addMouseOutHandler(new MouseOutHandler() {

public void onMouseOut(MouseOutEvent event) {
bulletpop.hide();
}
});
bullets.addClickListener(new ClickListener() {

public void onClick(Widget sender) {
ta.getExtendedFormatter().insertUnorderedList();

}
});

my first post

hi guys this is my first post just for checking

pulasthi

Amazon Deals