Windows XP Drivers for HP Compaq dx2400 Notebook

HP Compaq dx2400 Realtek High-Definition Audio Sound Driver
Download

HP Compaq dx2400 Intel Chipset Support for Microsoft Windows
Download

HP Compaq dx2400 ATI Graphics Video VGA Driver for Microsoft Windows XP
Download

HP Compaq dx2400 Intel Graphics VGA Driver for Microsoft Windows XP
Download

HP Compaq dx2400 NVIDIA Graphics VGA Driver for Microsoft Windows XP
Download

HP USB Smartcard Keyboard Drivers
Download

HP Compaq dx2400 Oxford Serial/Parallel PCI Card Driver
Download

HP Compaq dx2400 Broadcom Widcomm Bluetooth Software and Drivers
Download

HP Compaq dx2400 LSI (Agere) Systems Soft Modem Driver
Download

Broadcom NetXtreme Gigabit Ethernet Plus LAN Drivers
Download

HP Wireless 802.11b/g/n PCIe x1 Card WLAN Driver
Download

HP Compaq dx2400 Intel PRO/1000 Wireless Drivers for XP & Vista
Download

Intel Gigabit Network Connection Drivers for Windows XP
Download

HP Compaq dx2400 Realtek LAN Driver for Microsoft Windows XP
Download

HP Compaq dx2400 Belkin Wireless NIC Driver
Download

Windows XP Drivers for HP Compaq nc4400 Notebook

HP Compaq nc4400 Intel 915GM Graphics Video VGA Driver
Download

HP Compaq nc4400 Synaptics Touchpad Driver
Download

Agere Soft Modem Drivers for ICH6 Chipset for Windows XP
Download

HP Compaq nc4400 Intel PRO/Wireless WLAN Driver
Download

Broadcom WLAN Network Adapters Driver
Download

Texas Instruments Media Card Reader Driver
Download

HP Compaq nc4400 Media Card Reader Driver
Download

Intel PROSet for Intel PRO/Wireless Network Connection
Download

HP Wireless Assistant
Download

Compaq presario CQ40-317AU Driver

1. Netframework needed especially to install quicklaunch.
2. The audio must installed manually, you can read the installation guide i provided, of you still have problems leave your comments.

Install .Net Framework before others:
Download

ATI Radeon HD 3200 Graphics/Video Driver
Download (catalyst version 9.10) - (strongly recommended)
or
( if the driver above didn't work try this)
Download


MS UAA (required with a reboot before Audio driver)
Download


IDT High-Definition Audio CODEC Driver
Download ( SP41479.exe) - reported work
Download( reported worked)
Download (sp39545.exe) -reported work)
Download (sp45100.exe)  - strongly recommended
Download






Windows Installer 3.1(required before wireless)
here:
Download

If you have Intel PRO/Wireless Drivers
here:
Download

if you have Broadcom Wireless
here:
Download or
Download

Realtek RTL8102E Family PCI-E Fast Ethernet NIC
here:
Download

CARD READER
JMB38X Card Reader Host Controller
Download

ENE-CIR Reciever:
Download

for HDMI Audio
Download

ALPS Touchpad Driver
Download

or try this new driver (not sure it will work)
Download

HP Quick Launch Buttons
Download

If you have Bluetooth,
The HP Integrated Module is your Bluetooth Wireless
here:
Download

If you had for 7 unknown devices (buttons drivers)here:
Download (direct link)
Download (mediafire)

 

HP Compaq dc7700 Notebook

HP Compaq dc7700 Realtek High-Definition Audio Sound Driver
Download

Microsoft Windows XP SP2 Universal Audio Architecture Update (Q888111)
Download

HP Compaq dc7700 Intel Chipset Support for Windows
Download

HP Compaq dc7700 Intel Host Embedded Controller Interface (HECI) Driver
Download

HP Compaq dc7700 Intel Graphics Video VGA Driver for Windows XP
Download

HP Compaq dc7700 NVIDIA Graphics VGA Driver for Windows XP
Download

HP Compaq dc7700 ATI Graphics Driver for Windows XP
Download

HP USB Smartcard Keyboard Drivers
Download

HP Compaq dc7700 Broadcom Widcomm Bluetooth Software and Driver
Download

HP Compaq dc7700 LSI (Agere) Systems Soft Modem Driver
Download

HP Compaq dc7700 Intel PRO/1000 Wireless WLAN Drivers for XP & Vista
Download

HP Compaq dc7700 Broadcom NetXtreme Gigabit Driver
Download

HP Compaq dc7700 Belkin Wireless NIC WLAN Driver
Download

java applet

import java.applet.*;

 import java.awt.*;

 public class HelloWorld extends Applet {

       public void init() {

       resize(150,25);

       }//init

       public void paint(Graphics g) {

       g.setFont(new Font("Helvetica", Font.PLAIN, 8));

       g.drawString("Hello world!", 50, 25);

       }//paint

   }//HelloWorld

JDBC connectivity


The need of JDBC

Java has been called "the vehicle by which developers will be able to bring dynamic application behavior to the Web" . Users can download applets from either local or remote Web servers for execution inside popular Web browsers such as Netscape Navigat or. Applets run disconnected from the server, just like native applications. Java however, has fallen short of its widely ability to connect to outside resources via a build-in API. The first release of the Java Developers Kit (JDK) in early 1995 had no i ntegrated support for accessing databases. The functionality of Java made it easy to build tools for accessing databases, but there was no prescription about how such drivers ought to function. Several vendors produced good tools for database access but t here were no general guidelines for how database access tools should be written.

JavaSoft responded with the first release of the JDBC specification in May, 1996. The advent of JDBC means an end to those shortcomings mentioned. JDBC provides a vendor-neutral, universal framework for vendors to use in building tools that allow clien ts to access databases. The JDBC specification itself is just a collection of interfaces and abstract classes that each vendor must implement to write a JDBC-compliant driver. JDBC promises to database-enable any Java applet or application. It is included in the java.sql.package, which will be part of the Java Developers Kit (JDK) version 1.1.

JDBC Functionality

The JDBC API standard defines a set of Java classes required to perform standard relational database operations such as managing database connections, SQL statements, result sets, and metadata. JDBC specification has structural and conceptual similarit ies with Microsofts Open Database Connectivity (ODBC) driver, which Microsoft introduced in the 1980s to bring some conformity to client access to databases. It is based on the X/Open SQL Call Level Interface (CLI), the basis of ODBC. Like ODBC, JDBC giv es Java developers a common API to most relational databases, including client/server databases such as Oracle, Sybase, and Informix. The big difference is that JDBC builds on and reinforces the style and virtues of Java, and is easy to use.

JDBC sends a request to a database server using the appropriate SQL dialect and then processes the results (answer set). Using JDBC, it is easy to send SQL statements to virtually any relational database. It means that with the JDBC API it isnt necess ary to write one program to access a Sybase database, another program to access an Informix database, another program to access an Oracle database, and so on. A single program using the JDBC API can be written, and the program will be able to send SQL sta tements to the appropriate database.

Furthermore, with an application written in Java programming language, the programmer also doesnt have to worry about writing different applications to run on different platforms. The combination of Java and JDBC lets a programmer write it once and ru n it anywhere. Developers writing database access client applications for heterogeneous networks like being able to write one application that will run anywhere; that shortens the development process and makes application maintenance much easier than in t he traditional C/C++ world.

Like ODBC, the JDBC API uses a driver manager that simultaneously supports multiple database drivers for various databases. The driver(s) can be downloaded with the applet or exist as native drivers on the client, depending on how the security features of JDBC and Java will be implemented.

JDBC is a low-level interface used to invoke SQL commands, and it was also designed to be a base upon which to build higher-level interfaces and tools. A higher-level interface is user-friendly, and is translated into a low-level interface, such as JDB C. Later on I will mention two kinds of higher-level APIs under development on top of JDBC.

In summary, JDBC makes it possible to do three things:

establish a connection with a database
send SQL statements
process the results
The mechanism to communicate with database servers exist as standard Java classes. This ensures that the security features of Java remain and that JDBC code integrates cleanly in Java code. The JDBC API is expressed through several abstract Java interf aces that allow to link to any number of databases. The interfaces are:

java.sql.DriverManager: handles the loading and unloading of the appropriate database drivers required to make the connection.
java.sql.Connection: exposes the database to the developer, representing the connection as an accessible Java component.
java.sql.Statement: provides a container for executing SQL statements using a connection.
java.sql.ResultSet: exposes the data that returns from the database server to the Java application.
Two models for database access are supported by the JDBC API. They are the two-tier model and the three-tier model. The last one is mentioned more generally as a multitier.

The two-tier model

In the two-tier model, a Java applet or application talks directly to the database. This requires a JDBC driver that can communicate with the particular database management system (DBMS) being accessed. SQL statements are delivered to the database, and the results are sent back to the user.
 This is referred to as a client/server configuration, in which the users machine is the client and the machine housing the database is the server. The database may be located on another machine to which the user is connected via a network.

SQL Escape Sequences

SQL Server 2005



The Microsoft SQL Server 2005 JDBC Driver supports the use of SQL escape sequences, as defined by the JDBC API. Escape sequences are used within an SQL statement to tell the driver that the escaped part of the SQL string should be handled differently. When the JDBC driver processes the escaped part of an SQL string, it translates that part of the string into SQL code that SQL Server understands.
There are five types of escape sequences that the JDBC API requires, and all are supported by the JDBC driver:
  • LIKE wildcard literals
  • Function handling
  • Date and time literals
  • Stored procedure calls
  • Outer joins
The escape sequence syntax used by the JDBC driver is the following:
Function handling 
{fn functionName}
SELECT {fn UCASE(Name)} FROM Employee

HTTP and Other TCP Servers

public class rServerRegistrar {

public Thread[] cthreads;

public rServerRegistrar(Thread thr) {
cthreads=new Thread[1];
cthreads[0]=thr;
}

public void registerThread(Thread newthread) {
Thread[] tempthreads=new Thread[cthreads.length+1];
for(int i=0;i<cthreads.length;i++) {
tempthreads[i]=cthreads[i];
}
tempthreads[cthreads.length]=newthread;
cthreads=tempthreads;
}

public void deregisterThread(Thread delthread) {
Thread[] tempthreads=new Thread[cthreads.length-1];
int count=0;
for(int i=0;i<cthreads.length;i++) {
if(delthread.getName()!=cthreads[i].getName()) {
tempthreads[count]=cthreads[i];
count++;
}
}
cthreads=tempthreads;
}

private void updateThreads() {
int count=0; // First count the number of alive threads.
for(int i=0;i<cthreads.length;i++) {
if(cthreads[i].isAlive()) count++;
}
Thread[] temp=new Thread[count];
count=0;
for(int i=0;i<cthreads.length;i++) {
if(cthreads[i].isAlive()) {
temp[count]=cthreads[i];
count++;
}
}
}

public Thread[] getClientThreads() {
updateThreads(); // Return all except first thread.
Thread[] temp=new Thread[cthreads.length-1];
for(int i=0;i<temp.length;i++) {
temp[i]=cthreads[i+1];
}
return temp;
}

}

validationscript

<!-- Script by hscripts.com -->

/* Created on : Dec 1,2007 
   Javascript for validating a rounded integer value.
   This script validates the given input and returns true or false.
   You have to just call the function with the input as argument.
   Eg:var d = isInteger(3); returns true;
 var e = isInteger(4.4); returns false;*/

<script type="text/javascript">
function isInteger(s)
{
      var i;
 s = s.toString();
      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);
         if (isNaN(c)) 
    {
  alert("Given value is not a number");
  return false;
    }
      }
      return true;
}
</script>

<!-- Script by hscripts.com -->
 
HTML code
<!-- Script by hscripts.com -->

<form name=test>
<input type=text name=en onKeyup="isInteger(this.value)">
<input type=button name=cc value="Check" >
</form>

<!-- Script by hscripts.com -->

javascript validation


Using the form validation script

   1. Include gen_validatorv4.js in your html file just before closing the HEAD tag
      <script src="gen_validatorv4.js" type="text/javascript"></script>
      </head>
   2. Just after defining your form, create a Validator() object passing the name of the form
      <form id='myform' action="">
       <!----Your input fields go here -->
       </form>
      <script type="text/javascript">
       var frmvalidator  = new Validator("myform");
                           //where myform is the name/id of your form
   3. Now, add the validations required
      frmvalidator.addValidation("FirstName","req","Please enter your First Name");

      The format of the addValidation() function is:
      frmvalidator.addValidation(Field Name, Validation Descriptor, Error String);

      See below for the complete list of validation descriptors. The third parameter ( Error string ) is optional.
      You can add any number of validations to a field.
      frmvalidator.addValidation("FirstName","req","Please enter your First Name");
      frmvalidator.addValidation("FirstName","maxlen=40",
                                                "Max length for FirstName is 40");

Example

Here is a complete example:
<form action="" id="myform" >
<p>
    <label for='FirstName'>First Name:</label>
    <input type="text" id="FirstName" name="FirstName" />
</p>
<p>
    <label for='LastName'>Last Name:</label>
    <input type="text" id="LastName" name="LastName" />
</p>
<p>
    <label for='EMail'>EMail:</label>
    <input type="text" id="EMail" name="EMail" />
</p>
<p>
    <label for='Phone'>Phone:</label>
    <input type="text" id="Phone" name="Phone" />
</p>
<p>
    <label for='Address'>Address:</label>
    <textarea cols="20" rows="5" id="Address" name="Address"></textarea>
</p>
<p>
    <label for='Country'>Country:</label>
    <select id="Country"  name="Country">
        <option value="000" selected="selected">[choose yours]</option>
        <option value="008">Albania</option>
        <option value="012">Algeria</option>
        <option value="016">American Samoa</option>
        <option value="020">Andorra</option>
        <option value="024">Angola</option>
        <option value="660">Anguilla</option>
        <option value="010">Antarctica</option>
        <option value="028">Antigua And Barbuda</option>
        <option value="032">Argentina</option>
        <option value="051">Armenia</option>
        <option value="533">Aruba</option>
    </select>
</p>
<p>
    <input type="submit" name="submit" value="Submit">
</p>
</form>
<script  type="text/javascript">
 var frmvalidator = new Validator("myform");
 frmvalidator.addValidation("FirstName","req","Please enter your First Name");
 frmvalidator.addValidation("FirstName","maxlen=20",
        "Max length for FirstName is 20");
 frmvalidator.addValidation("LastName","req");
 frmvalidator.addValidation("LastName","maxlen=20");
 frmvalidator.addValidation("Email","maxlen=50");
 frmvalidator.addValidation("Email","req");
 frmvalidator.addValidation("Email","email");
 frmvalidator.addValidation("Phone","maxlen=50");
 frmvalidator.addValidation("Phone","numeric");
 frmvalidator.addValidation("Address","maxlen=50");
 frmvalidator.addValidation("Country","dontselect=000");
</script>

.NET

Welcome to this ASP.NET tutorial. According to Microsoft, "ASP.NET is a technology for building powerful, dynamic Web applications and is part of the .NET Framework". This tutorial will teach you ASP.NET from scratch, and no knowledge of any kind of serverside scripting is required. Basic HTML and CSS knowledge is preferable. Having worked with Classic ASP or PHP won't give you much of an advantage, since ASP.NET is a whole new way of doing things.

.NET is language independent, which means you can use any .NET supported language to make .NET applications. The most common languages for writing ASP.NET applications are C# and VB.NET. While VB.NET is directly based VB (Visual Basic), C# was introduced together with the .NET framework, and is therefore a some what new language. Some people call C# "the .NET language", but according to Microsoft, you can do all the same things, no matter if you're using C# or VB.NET. The 2 languages are not that different, and if you have used one of them, you will have no problems at all learning the other. In this tutorial we will use C#.

One of the main differences between ASP.NET and Classic ASP/PHP is the fact that ASP.NET is compiled, while Classic ASP is always interpreted. PHP can be compiled by using commercial products, but usually it's interpreted as well.

This tutorial will use the free Visual Web Developer IDE from Microsoft. Despite what some people think, ASP.NET can be used without an IDE. It would be perfectly possible to write ASP.NET code in Notepad, and use the commandline compiler included with the .NET framework. Some people might actually prefer this "back to basics" way of doing things, but I believe that ASP.NET is best programmed with a decent IDE. You can use an IDE from another vendor, and you will still be able to follow most of this tutorial. We will use VWD 2008 since it's free, quick to install and easy to use. Besides, using a good IDE will make a lot of things faster in the long run.

Now, you can read more about VWD 2008 on this page: http://www.microsoft.com/express/vwd/Default.aspx and download it from this page: http://www.microsoft.com/express/download/. The initial download is very small, because the installation is based on which components you already have and which will have to be downloaded. Just execute the file, and you will be guided through the installation. Once installed, start up the application, and proceed to the next chapter.

Javavscript

Introduction to JavaScript

JavaScript is a programming language that can be included on web pages to make them more interactive. You can use it to check or modify the contents of forms, change images, open new windows and write dynamic page content. You can even use it with CSS to make DHTML (Dynamic HyperText Markup Language). This allows you to make parts of your web pages appear or disappear or move around on the page. JavaScripts only execute on the page(s) that are on your browser window at any set time. When the user stops viewing that page, any scripts that were running on it are immediately stopped. The only exceptions are cookies or various client side storage APIs, which can be used by many pages to store and pass information between them, even after the pages have been closed.
Before we go any further, let me say; JavaScript has nothing to do with Java. If we are honest, JavaScript, originally nicknamed LiveWire and then LiveScript when it was created by Netscape, should in fact be called ECMAscript as it was renamed when Netscape passed it to the ECMA for standardisation.
JavaScript is a client side, interpreted, object oriented, high level scripting language, while Java is a client side, compiled, object oriented high level language. Now after that mouthful, here's what it means.
Client side
Programs are passed to the computer that the browser is on, and that computer runs them. The alternative is server side, where the program is run on the server and only the results are passed to the computer that the browser is on. Examples of this would be PHP, Perl, ASP, JSP etc.
Interpreted
The program is passed as source code with all the programming language visible. It is then converted into machine code as it is being used. Compiled languages are converted into machine code first then passed around, so you never get to see the original programming language. Java is actually dual half compiled, meaning it is half compiled (to 'byte code') before it is passed, then executed in a virtual machine which converts it to fully compiled code just before use, in order to execute it on the computer's processor. Interpreted languages are generally less fussy about syntax and if you have made mistakes in a part they never use, the mistake usually will not cause you any problems.
Scripting
This is a little harder to define. Scripting languages are often used for performing repetitive tasks. Although they may be complete programming languages, they do not usually go into the depths of complex programs, such as thread and memory management. They may use another program to do the work and simply tell it what to do. They often do not create their own user interfaces, and instead will rely on the other programs to create an interface for them. This is quite accurate for JavaScript. We do not have to tell the browser exactly what to put on the screen for every pixel (though there is a relatively new API known as canvas that makes this possible if needed), we just tell it that we want it to change the document, and it does it. The browser will also take care of the memory management and thread management, leaving JavaScript free to get on with the things it wants to do.
High level
Written in words that are as close to english as possible. The contrast would be with assembly code, where each command can be directly translated into machine code.

PHP

Introduction

Up until recently, scripting on the internet was something which very few people even attempted, let alone mastered. Recently though, more and more people have been building their own websites and scripting languages have become more important. Because of this, scripting languages are becomming easier to learn and PHP is one of the easiest and most powerful yet.

What Is PHP?

PHP stands for Hypertext Preprocessor and is a server-side language. This means that the script is run on your web server, not on the user's browser, so you do not need to worry about compatibility issues. PHP is relatively new (compared to languages such as Perl (CGI) and Java) but is quickly becomming one of the most popular scripting languages on the internet.

Why PHP?

You may be wondering why you should choose PHP over other languages such as Perl or even why you should learn a scripting language at all. I will deal with learning scripting languages first. Learning a scripting language, or even understanding one, can open up huge new possibilities for your website. Although you can download pre-made scripts from sites like Hotscripts, these will often contain advertising for the author or will not do exactly what you want. With an understanding of a scripting language you can easily edit these scripts to do what you want, or even create your own scripts.

Using scripts on your website allows you to add many new 'interactive' features like feedback forms, guestbooks, message boards, counters and even more advanced features like portal systems, content management, advertising managers etc. With these sort of things on your website you will find that it gives a more professional image. As well as this, anyone wanting to work in the site development industry will find that it is much easier to get a job if they know a scripting language.

What Do I Need?

As mentioned earlier, PHP is a server-side scripting language. This means that, although your users will not need to install new software, you web host will need to have PHP set up on their server. It should be listed as part of your package but if you don't know if it is installed you can find out using the first script in this tutorial. If you server does not support PHP you can ask your web host to install it for you as it is free to download and install. If you need a low cost web host which supports PHP I would recommmend HostRocket.

Writing PHP

Writing PHP on your computer is actually very simple. You don't need any specail software, except for a text editor (like Notepad in Windows). Run this and you are ready to write your first PHP script.

Declaring PHP

PHP scripts are always enclosed in between two PHP tags. This tells your server to parse the information between them as PHP. The three different forms are as follows:

<?
PHP Code In Here
?>

<?php
PHP Code In Here
php?>

<script language="php">
PHP Code In Here
</script>

All of these work in exactly the same way but in this tutorial I will be using the first option (<? and ?>). There is no particular reason for this, though, and you can use either of the options. You must remember, though, to start and end your code with the same tag (you can't start with <? and end with </script> for example).

Your First Script

The first PHP script you will be writing is very basic. All it will do is print out all the information about PHP on your server. Type the following code into your text editor:

<?
phpinfo();
?>

As you can see this actually just one line of code. It is a standard PHP function called phpinfo which will tell the server to print out a standard table of information giving you information on the setup of the server.

One other thing you should notice in this example is th
at the line ends in a semicolon. This is very important. As with many other scripting and programming languages nearly all lines are ended with a semicolon and if you miss it out you will get an error.

Finishing and Testing Your Script

Now you have finished your script save it as phpinfo.php and upload it to your server in the normal way. Now, using your browser, go the the URL of the script. If it has worked (and if PHP is installed on your server) you should get a huge page full of the information about PHP on your server.

If your script doesn't work and a blank page displays, you have either mistyped your code or your server does not support this function (although I have not yet found a server that does not). If, instead of a page being displayed, you are prompted to download the file, PHP is not installed on your server and you should either serach for a new web host or ask your current host to install PHP.

XML introduction

XML, the Extensible Markup Language, has gone from the latest buzzword to an entrenched eBusiness technology in record time. This newly revised tutorial discusses what XML is, why it was developed, and how it's shaping the future of electronic commerce. It also covers a variety of important XML programming interfaces and standards, and ends with two case studies showing how companies are using XML to solve business problems.

  • Why XML was created
  • The rules of XML documents
  • How to define what an XML document can and cannot contain
  • Programming interfaces that work with XML documents
  • What the main XML standards are and how they work together
  • How companies are using XML in the real world

Applications of XML

Although there are countless numbers of applications that use XML, here are a few examples of the current platforms and applications that are making use of this technology:
  • Cell Phones - XML data is sent to some cell phones. The data is then formatted by the specification of the cell phone software designer to display text or images, and even to play sounds!
  • File Converters - Many applications have been written to convert existing documents into the XML standard. An example is a PDF to XML converter.
  • VoiceXML - Converts XML documents into an audio format so that you can listen to an XML document.

Inheritance interface

A Java Class

class Point {
   public double x, y; 
   public static Point origin = new Point(0,0); 
     // This always refers to an object at (0,0) 
   Point(double x_value, double y_value) {
      x = x_value; 
      y = y_value; 
   }
   public void clear() {
      this.x = 0; 
      this.y = 0; 
   }
   public double distance(Point that) {
      double xDiff = x - that.x; 
      double yDiff = y - that.y; 
      return Math.sqrt(xDiff * xDiff + yDiff * yDiff);
   }
}

Extending a Class: Inheritance

class Pixel extends Point {
  Color color; 

  public void clear() {
     super.clear(); 
     color = null; 
  }
}

Interfaces

interface Lookup {
   /** Return the value associated with the name, or 
    * null if there is no such value */ 
    Object find(String name); 
}

void processValues(String[] names, Lookup table) {
   for (int i = 0; i ! names.length; i++) {
       Object value = table.find(names[i]); 
       if (value != null) 
          processValue(names[i], value); 
   }
}

class SimpleLookup implements Lookup {
   private String[] Names; 
   private Object[] Values; 

   public Object find(String name) {
      for (int i = 0; i < Names.length; i++) {
          if (Names[i].equals(name)) 
             return Values[i]; 
      }
      return null; // not found 
   }
   // ... 
}

Creating Threads in Java

public class PingPONG extends Thread { 
    private String word; // What word to print  
    private int delay; // how long to pause  
    public PingPONG(String whatToSay, int delayTime) { 
        word = whatToSay;  
        delay = delayTime;  
    } 
    public void run() { 
        try { 
            for (;;) { 
                System.out.print(word + " ");  
                sleep(delay); // wait until next time  
            } 
        } catch (InterruptedException e) { 
            return; // end this thread;  
        } 
    } 
    public static void main(String[] args) { 
        new PingPONG("Ping", 33).start(); // 1/30 second  
        new PingPONG("PONG",100).start(); // 1/10 second  
    } 
} 

Two Synchronization Methods

class Account {
    private double balance; 
    Public Account(double initialDeposit) {
       balance = initialDeposit; 
    }
    public synchronized double getBalance() {
       return balance; 
    }
    public synchronized viod deposit(double amount) {
       balance += amont; 
    }
}

/** make all elements in the array non-negative */ 
public static void abs(int[] values) {
    synchronized (values) {
       for (int i = 0; i < values.length; i++) {
          if (values[i] < 0)
             values[i] = -values[i]; 
       }
    }
}

Java Basics

Java is a high-level programming language originally developed by Sun Microsystems and released in 1995.
Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
This tutorial gives a complete understanding on Java.

History of Java

James Gosling initiated the Java language project in June 1991 for use in one of his many set-top box projects. The language, initially called Oak after an oak tree that stood outside Gosling's office, also went by the name Green and ended up later renamed as Java, from a list of random words.
Sun released the first public implementation as Java 1.0 in 1995. It promised Write Once, Run Anywhere (WORA), providing no-cost run-times on popular platforms.
On 13 November 2006, Sun released much of Java as free and open source software under the terms of the GNU General Public License (GPL).
On 8 May 2007 Sun finished the process, making all of Java's core code free and open-source, aside from a small portion of code to which Sun did not hold the copyright.

Java programming language was originally developed by Sun Microsystems, which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems.s Java platform (Java 1.0 [J2SE]).
As of December 08 the latest release of the Java Standard Edition is 6 (J2SE). With the advancement of Java and its wide spread popularity, multiple configurations were built to suite various types of platforms. Ex: J2EE for Enterprise Applications, J2ME for Mobile Applications.
Sun Microsystems has renamed the new J2 versions as Java SE, Java EE and Java ME respectively. Java is guaranteed to be Write Once, Run Anywhere

A Revised Version of Hello World

import java.io.*; 
class MyFirstProgram {
  /** Print a hello message */ 
  public static void main(String[] args) { 
    BufferedReader in = 
        new BufferedReader(new InputStreamReader(System.in)); 
    String name = "Instructor"; 
    System.out.print("Give your name: "); 
    try {name = in.readLine();}
        catch(Exception e) {
           System.out.println("Caught an exception!"); 
        }
    System.out.println("Hello " + name + "!"); 
  }
}


Javascript shorthand coding

1. If true … else Shorthand

This is a great code saver for when you want to do something if the test is true, else do something else by using the ternary operator.

Longhand:
var big;
if (x > 10) {
    big = true;
}
else {
    big = false;
}
Shorthand:
var big = (x > 10) ? true : false;
If you rely on some of the weak typing characteristics of JavaScript, this can also achieve more concise code. For example, you could reduce the preceding code fragment to this:
var big = (x > 10);

//further nested example
x = 3;
var big = (x > 10) ? "greater 10" : (x < 5) ? "less 5" : "between 5 and 10";
console.log(big); //"less 5"

2. Null, Undefined, Empty Checks Shorthand

When creating new variables sometimes you want to check if the variable your referencing for it’s value isn’t null or undefined. I would say this is a very common check for JavaScript coders.
Longhand:
if (variable1 !== null || variable1 !== undefined || variable1 !== '') {
     var variable2 = variable1;
}
Shorthand:
var variable2 = variable1  || '';
Don’t believe me? Test it yourself (paste into Firebug and click run):
//null value example
var variable1 = null;
var variable2 = variable1  || '';
console.log(variable2);
//output: '' (an empty string)

//undefined value example
var variable1 = undefined;
var variable2 = variable1  || '';
console.log(variable2);
//output: '' (an empty string)

//normal value example
var variable1 = 'hi there';
var variable2 = variable1  || '';
console.log(variable2);
//output: 'hi there'

3. Object Array Notation Shorthand

Useful way of declaring small arrays on one line.
Longhand:
var a = new Array();
a[0] = "myString1";
a[1] = "myString2";
a[2] = "myString3";
Shorthand:
var a = ["myString1", "myString2", "myString3"];

4. Associative Array Notation Shorthand

The old school way of setting up an array was to create a named array and then add each named element one by one. A quicker and more readable way is to add the elements at the same time using the object literal notation.
Longhand:
var skillSet = new Array();
skillSet['Document language'] = 'HTML5';
skillSet['Styling language'] = 'CSS3';
skillSet['Javascript library'] = 'jQuery';
skillSet['Other'] = 'Usability and accessibility';
Shorthand:
var skillSet = {
    'Document language' : 'HTML5',
    'Styling language' : 'CSS3',
    'Javascript library' : 'jQuery',
    'Other' : 'Usability and accessibility'
};
Don’t forget to omit the final comma otherwise certain browsers will complain (not naming any names, IE).

5. Declaring variables Shorthand

It is sometimes good practice to including variable assignments at the beginning of your functions. This shorthand method can save you lots of time and space when declaring multiple variables at the same time.
longhand:
var x;
var y;
var z = 3;
shorthand:
var x, y, z=3;

6. Assignment Operators Shorthand

Assignment operators are used to assign values to JavaScript variables and no doubt you use arithmetic everyday without thinking (no matter what programming language you use Java, PHP, C++ it’s essentially the same principle).
Longhand:
x=x+1;
minusCount = minusCount - 1;
y=y*10;
Shorthand:
x++;
minusCount --;
y*=10;
Other shorthand operators, given that x=10 and y=5, the table below explains the assignment operators:
x += y //result x=15
x -= y //result x=5
x *= y //result x=50
x /= y //result x=2
x %= y //result x=0

7. Regex Object Shorthand

In Javascript, a Regex object can be called like a function like so:
/test/("is test in here")
As opposed to the more verbose(but sometimes more appropriate in cases that you are reusing the Regex).
Longhand:
searchText = "padding 1234 rocket str austin TX 78704 more padding"
/\d+.+\n{0,2}.+\s+[A-Z]{2}\s+\d{5}/m(searchText)
//returns: ["1234 rocket str austin TX 78704"]
Shorthand:
var re = new RegExp(/\d+.+\n{0,2}.+\s+[A-Z]{2}\s+\d{5}/m);
re.exec(searchText);
//returns: ["1234 rocket str austin TX 78704"]

8. If Presence Shorthand

This might be trivial, but worth a mention. When doing “if checks” assignment operators can sometimes be ommited.
Longhand:
if (likeJavaScript == true)
Shorthand:
if (likeJavaScript)
Here is another example. If “a” is NOT equal to true, then do something.
Longhand:
var a;
if ( a != true ) {
// do something...
}
Shorthand:
var a;
if ( !a ) {
// do something...
}

9. Function Variable Arguments Shorthand

Object literal shorthand can take a little getting used to, but seasoned developers usually prefer it over a series of nested functions and variables. You can argue which technique is shorter, but I enjoy using object literal notation as a clean substitute to functions as constructors.
Longhand:
function myFunction( myString, myNumber, myObject, myArray, myBoolean ) {
 // do something...
}
myFunction( "String", 1, [], {}, true );
Shorthand (looks long but only because I have console.log’s in there!):
function myFunction() {
 console.log( arguments.length ); // Returns 5
 for ( i = 0; i < arguments.length; i++ ) {
  console.log( typeof arguments[i] ); // Returns string, number, object, object, boolean
 }
}
myFunction( "String", 1, [], {}, true );

10. JavaScript foreach Loop Shorthand

This little tip is really useful if you want plain JavaScript and hence can’t use the awesome jQuery.each.
Longhand:
for (var i = 0; i < allImgs.length; i++)
Shorthand:
for(var i in allImgs)

11. charAt() Shorthand

You can use the eval() function to do this but this bracket notation shorthand technique is much cleaner than an evaluation, and you will win the praise of colleagues who once scoffed at your amateur coding abilities!
Longhand:
"myString".charAt(0);
Shorthand:
"myString"[0]; // Returns 'm'

JavaScript string functions in action



1. charAt(x) Returns the character at the “x” position within the string.

//charAt(x)
var myString = 'jQuery FTW!!!';
console.log(myString.charAt(7));
//output: F

2. charCodeAt(x) Returns the Unicode value of the character at position “x” within the string.

//charAt(position)
var message="jquery4u"
//alerts "q"
alert(message.charAt(1))

3. concat(v1, v2,…) Combines one or more strings (arguments v1, v2 etc) into the existing one and returns the combined string. Original string is not modified.

//concat(v1, v2,..)
var message="Sam"
var final=message.concat(" is a"," hopeless romantic.")
//alerts "Sam is a hopeless romantic."
alert(final)

4. fromCharCode(c1, c2,…) Returns a string created by using the specified sequence of Unicode values (arguments c1, c2 etc). Method of String object, not String instance. For example: String.fromCharCode().

//fromCharCode(c1, c2,...)
console.log(String.fromCharCode(97,98,99,120,121,122))
//output: abcxyz
console.log(String.fromCharCode(72,69,76,76,79))
//output: HELLO
//(PS - I have no idea why you would use this? any ideas?)

Also see: Full List of JavaScript Character Codes

5. indexOf(substr, [start]) Searches and (if found) returns the index number of the searched character or substring within the string. If not found, -1 is returned. “Start” is an optional argument specifying the position within string to begin the search. Default is 0.

//indexOf(char/substring)
var sentence="Hi, my name is Sam!"
if (sentence.indexOf("Sam")!=-1)
alert("Sam is in there!")

6. lastIndexOf(substr, [start]) Searches and (if found) returns the index number of the searched character or substring within the string. Searches the string from end to beginning. If not found, -1 is returned. “Start” is an optional argument specifying the position within string to begin the search. Default is string.length-1.

//lastIndexOf(substr, [start])
var myString = 'javascript rox';
console.log(myString.lastIndexOf('r'));
//output: 11

7. match(regexp) Executes a search for a match within a string based on a regular expression. It returns an array of information or null if no match is found.

//match(regexp) //select integers only
var intRegex = /[0-9 -()+]+$/; 

var myNumber = '999';
var myInt = myNumber.match(intRegex);
console.log(isInt);
//output: 999

var myString = '999 JS Coders';
var myInt = myString.match(intRegex);
console.log(isInt);
//output: null

Also see: jQuery RegEx Examples to use with .match()

8. replace(regexp/substr, replacetext) Searches and replaces the regular expression (or sub string) portion (match) with the replaced text instead.

//replace(substr, replacetext)
var myString = '999 JavaScript Coders';
console.log(myString.replace(/JavaScript/i, "jQuery"));
//output: 999 jQuery Coders

//replace(regexp, replacetext)
var myString = '999 JavaScript Coders';
console.log(myString.replace(new RegExp( "999", "gi" ), "The"));
//output: The JavaScript Coders

9. search(regexp) Tests for a match in a string. It returns the index of the match, or -1 if not found.

//search(regexp)
var intRegex = /[0-9 -()+]+$/; 

var myNumber = '999';
var isInt = myNumber.search(intRegex);
console.log(isInt);
//output: 0

var myString = '999 JS Coders';
var isInt = myString.search(intRegex);
console.log(isInt);
//output: -1

10. slice(start, [end]) Returns a substring of the string based on the “start” and “end” index arguments, NOT including the “end” index itself. “End” is optional, and if none is specified, the slice includes all characters from “start” to end of string.

//slice(start, end)
var text="excellent"
text.slice(0,4) //returns "exce"
text.slice(2,4) //returns "ce"

11. split(delimiter, [limit]) Splits a string into many according to the specified delimiter, and returns an array containing each element. The optional “limit” is an integer that lets you specify the maximum number of elements to return.

//split(delimiter)
var message="Welcome to jQuery4u"
//word[0] contains "We"
//word[1] contains "lcome to jQuery4u"
var word=message.split("l")

12. substr(start, [length]) Returns the characters in a string beginning at “start” and through the specified number of characters, “length”. “Length” is optional, and if omitted, up to the end of the string is assumed.

//substring(from, to)
var text="excellent"
text.substring(0,4) //returns "exce"
text.substring(2,4) //returns "ce"

13. substring(from, [to]) Returns the characters in a string between “from” and “to” indexes, NOT including “to” inself. “To” is optional, and if omitted, up to the end of the string is assumed.

//substring(from, [to])
var myString = 'javascript rox';
myString = myString.substring(0,10);
console.log(myString)
//output: javascript

14. toLowerCase() Returns the string with all of its characters converted to lowercase.

//toLowerCase()
var myString = 'JAVASCRIPT ROX';
myString = myString.toLowerCase();
console.log(myString)
//output: javascript rox

15. toUpperCase() Returns the string with all of its characters converted to uppercase.

//toUpperCase()
var myString = 'javascript rox';
myString = myString.toUpperCase();
console.log(myString)
//output: JAVASCRIPT ROX

comments