Language / DB Resource
Java Code and Framework Concepts
Java Environment :

You can run java programs on a wide variety of computer using a range of operating system. Your java programs will run just as well on a PC running Windows 95/98/NT/2000 as it will on Linux or a Sun Solaris workstation. This is possible because a java program does not execute directly on your computer. It runs on a standardized hypothetical computer that is called the java virtual machine or JVM. Which is emulated inside your computer by a program.

A java compiler converts the java source code that you write into a binary program consisting of byte codes. Byte codes are machine instructions for the java virtual machine. When you execute a java program, a program called the java interpreter inspects and deciphers the byte codes for it, checks it out to ensure that it has not been tampered with and is safe to execute, and then executes the actions that the byte codes specify within the java virtual machine. A java interpreter can run stand-alone, or it be invoked automatically to run applets in a Web page.

Because your java program consists of byte codes rather than native machine instructions, it is completely insulated from the particular hardware on which it is run. Any computer that has the java environment implemented will handle your program as any other, and because the java interpreter sits between your program and the physical machine, it can prevent unauthorized actions in the program from being executed

Services
Software Development
Web Development
Graphic Designing
Tools & Technologies
Multimedia Services
Web Marketing & SEO
Web Designing
Pakages in Java and thier descriptions
Java.io Classes for data input and output operations.
Java.util This package contains utility classes of various kinds,
Including classes for managing data within collections or
groups of data items
Javax.swing These classes provide easy-to-use and flexible components for building graphical user interfaces(GUIs). The components in
this package are referred to as components.
Java.awt Classes in this package provide the original GUI Components(JDK1.1) as well s some basic support necessary for Swing components.
Java.awt.image These classes support image handling
Java.awt.event The classes in this package are used in the implementation of windowed application to handle events in your program.
Events are things like moving the mouse, pressing the left
mouse button, or clicking on a menu item.
 
     
Data Types in Java and their descriptions
Byte Variables of this type can have values from -128 to +127 and.
occupy 1 byte (8bits) in memory.
Short Variables of this type can have value from -32768 to 32767
and occupy 4 bytes (32 bits) in memory.
Int

Variables of this type can have values from -2147483648 to 2147483647 and occupy 4 bytes (32 bits) in memory.

Long Variables of this type can have values from -9223372036854775808 to -9223372036854775808 and occupy 8 bytes (64 bytes) in memory.
Float Variables of this type can have values from -3.4E38 to +3.4E38 and occupy 4 bytes in memory.
Double Variables of this type can have values from -1.7 * 10E308 to +1.7 * 10E308and occupy 8 bytes in memory.  
   
     
Code Explanation :

public static void main (String[] args)

public : This specifies that main() is accessible from outside of the class.

Static : This specifies that main() exists without any objects being defined.

Void : This specifies that main() does not return any value .

       
 
Java Script function for checking Email format :
function checkEmail()
{
var strEmail, strError, countAtRate, countDot, i;
var checkAtRate, checkDot;
var ValidChars,CountValidChars;
ValidChars="abcdefghijklmnopqrstuvwxyz0123456789-_.@ABCDEFGHIJKLMNOPQRSTUVWXYZ";
strEmail = checkEmail.arguments[0];
countAtRate=0;
countDot=0;
CountValidChars=0;
if (strEmail.length >= 7)
{
for(i=0;i<strEmail.length;i++)
{
if(strEmail.charAt(i)=="@")
countAtRate++;
if(strEmail.charAt(i)==".")
countDot++;
CountValidChars=0;
for(j=0;j<ValidChars.length;j++)
{
if(strEmail.charAt(i)==ValidChars.charAt(j))
{
CountValidChars++;
}
}
if(CountValidChars==0)
{
strError=0;
break;
}
}
}
checkAtRate=strEmail.indexOf("@",1);
checkDot=strEmail.indexOf(".",1);
for(i=1;i<countDot;i++)
checkDot=strEmail.indexOf(".",checkDot+1);
if(countAtRate==1 && countDot > 0 && strEmail.length >=7 && strError != 0)
strError=1;
else
strError=0;
if(checkDot>=strEmail.length-2)
strError=0;
if(strEmail.charAt(0)=="@" || strEmail.charAt(strEmail.length-1)=="@")
strError=0;
if(strEmail.charAt(0)=="." || strEmail.charAt(strEmail.length-1)==".")
strError=0;
if(checkDot < checkAtRate)
strError=0;

return strError;
}

 
 
 
   
       
 
Java Script Function for Checking Numeric Value :
function checkNumeric()
{
var valNumber, valString, countNumber, varReturn;
valString="0123456789.";
countNumber=0;
valNumber=checkNumeric.arguments[0];
for (i=0;i<valNumber.length;i++)
for(j=0;j<valString.length;j++)
if(valString.charAt(j)==valNumber.charAt(i))
countNumber++;
if(valNumber.length==countNumber && valNumber.length>0)
varReturn=1;
else
varReturn=0;
return varReturn;
}
 
           
   
Date Function for Client side Validation
<script language = "Javascript">
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
var i;
for (i = 0; i < s.length; i++){
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function stripCharsInBag(s, bag){
var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++){
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}

function daysInFebruary (year){
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 31
if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
if (i==2) {this[i] = 29}
}
return this
}

function isDate(dtStr){
var daysInMonth = DaysArray(12)
var pos1=dtStr.indexOf(dtCh)
var pos2=dtStr.indexOf(dtCh,pos1+1)
var strMonth=dtStr.substring(0,pos1)
var strDay=dtStr.substring(pos1+1,pos2)
var strYear=dtStr.substring(pos2+1)
strYr=strYear
if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if (pos1==-1 || pos2==-1){
alert("The date format should be : mm/dd/yyyy")
return false
}
if (strMonth.length<1 || month<1 || month>12){
alert("Please enter a valid month")
return false
}
if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
alert("Please enter a valid day")
return false
}
if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
return false
}
if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
alert("Please enter a valid date")
return false
}
return true
}

function ValidateForm(){
var dt=document.frmSample.txtDate
if (isDate(dt.value)==false){
dt.focus()
return false
}
return true
}

</script>

<form name="frmSample" method="post" action="" onSubmit="return ValidateForm()">
<p>Enter a Date <font color="#CC0000"><b>(mm/dd/yyyy)</b></font>
:
<input type="text" name="txtDate" maxlength="10" size="15">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>

   
     
           
 
© Copyrights ideallogics.com. all rights reserved.