The Memory Usage by a Java Program

The instructions of a running program and the related data are temporarily stored in the computer memory. Java has good news for you here: you don’t need to worry about memory management because the JVM and garbage collector will take care of it. However, you can help by being aware of where different things are stored in the memory. This will also help you to understand how objects are created. As shown in Figure 1-4, a program’s data is placed in two different areas in memory: the stack and the heap. Stack and heap refers to the different ways (or places) to store the elements of a running program in memory.

Java Memory Stack Heap

Living on the Stack

The following elements of a Java program live on the stack:

  • Local variables: The variables of primitive types defined inside a method or as method parameters.
  • Local reference variables: The variables that refer to an object and are defined inside a method or as a method parameter. Remember that an object that a local variable refers to lives on the heap and not on the stack.
  • Method invocations: When you invoke (call) a method, the method is pushed onto the stack (that is, placed on top of the stack).

Local variables live inside a method, and the scope of a local variable is the execution of the method. When the method execution is complete, the local variables inside the method are gone. But the objects, to which some of these local variables may be referring, are still alive and well on the heap.

Living on the Heap

The following elements of a Java program live on the heap:

  • Instance variables: The variables of primitive types defined inside a class but outside of all its methods.
  • Instance reference variables: The variables that refer to an object and are defined inside a class but outside of all its methods.
  • Objects: Represent the entities in the real-world problem that the Java program is trying to solve. All the objects live on the heap, always.

Remembering whether a particular element lives on the stack or on the heap is easy: a local variable (primitive or reference) belongs to a method and lives with it on the stack, while an instance variable belongs to an object and lives with it on a heap. However, also note that a local reference variable on a stack points to an object on the heap, and the object will not die with the local reference variable.

The objects on the heap that are no longer in use are eventually collected by a program called a garbage collector to free up the memory used by them. For this reason, the heaps are also called garbage-collectible heaps.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blogmarks
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

The instanceof Operator in Java

The instanceof operator determines if a given object is of the type of a specific class. To be more specific, the instanceof operator tests whether its first operand is an instance of its second operand. The test is made at runtime. The first operand is supposed to be the name of an object or an array element, and the second operand is supposed to be the name of a class, interface, or array type. The syntax is

<op1> instanceof <op2>

The result of this operation is a boolean: true or false. If an object specified by <op1> is an instance of a class specified by <op2>, the outcome of the operation is true, and otherwise is false. The outcome of the operation will also be true if <op2> specifies an interface that is implemented either by the class of the object specified by <op1> or by one of its superclasses. For example, consider the following code fragment:

interface X{}
class A implements X {}
class B extends A {}
A a = new A();
B b = new B();

Note that class B does not implement the interface X directly, but class A does, and class B extends class A. Given this code, all of the following statements are true:

if( b instanceof X)
if (b instanceof B)
if(b instance of A)
if(a instance of A)
if(a instanceof X)

Knowing the type of an object at runtime is useful for the following reasons:

  • Some invalid casts (explicit type conversions) involving class hierarchies cannot be caught at compile time. Therefore, they must be checked at runtime (using the instanceof operator), to avoid a runtime error.
  • You might have a situation where one process is generating various kinds of objects, and the other process is processing them. The other process may need to know the object type before it can properly process it. In this situation the instanceof operator would be helpful, too.
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blogmarks
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Ultimate Firefox extensions for Developers

Firefox has now been downloaded 165,123,014 times, inspiring hundreds of fantastic extensions. Rob Buckley presents the fifteen you really can’t afford to miss.

At the top of the list of things for web developers to remember should be a reminder that whatever can go wrong, will go wrong. Only the simplest of web page designs can make it from authoring app to the real world without having to undergo a few tweaks caused by browser incompatibility, accessibility problems, server issues or coding mistakes.

The main issues arise from the fact that pinning down problems in web pages really isn’t as simple a task as you might hope. Web browsers are designed to be easy to use, so filling them up with complex debugging tools is not an ideal solution. Browser developers might not be interested in adding webdebugging tools to their software, but that doesn’t mean no one else can. If a browser has a simple, open extension architecture, anyone can add new features to it and make it do more or less anything they want.

The most extensible of all browsers is Firefox, which now has over 1,000 extensions. These are almost all cross-platform, so they work on Macs and Linux machines as well as Windows. They include debugging consoles, syntax validators, cookie manipulators, accessibility tools, manuals, measurement tools and search engine optimisation information. Add to that extensions that can rewrite the pages and stylesheets you’re using and suddenly Firefox becomes by far the most developer-friendly of all the browsers available.

Over the next three pages, we’re going to show you what the best 15 Firefox extensions can do for you, as well as look at some of the plug-ins available for other browsers. Installing an extension is easy: just click on the install link provided on each download page, give the site permission, and Firefox will be able to download and install the extension. Provided it’s compatible with the version of Firefox you’re using, the extension should be up and running as soon as you restart the browser.

1 Web Developer
http://chrispederick.com/work/webdeveloper

If there’s one Firefox extension to rule them all, it’s the Web Developer toolbar. It has a huge number of features, so we’ll start with the most useful. Often, you’ll need to work out exactly which styles apply to a page element with Web Developer installed, just click ‘View Style Information’ and every time you mouse over an element, the styles applied to it will appear in your status bar.

And there are plenty more goodies: you can outline highlights, common elements and links without title tags; images show sizes, alt tags and oversized images; forms enable you to manipulate form elements and submission methods; cookies enable you to add, delete and disable cookies; and there’s much more. Indispensable!

Continue Reading…

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blogmarks
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

The Process of website indexing by Google & other Search Engines

There is a lot of speculation about how search engines index websites. The topic is shrouded in mystery about exact working of search engine indexing process since most search engines offer limited information about how they architect the indexing process. Webmasters get some clues by checking their log reports about the crawler visits but are unaware of how the indexing happens or which pages of their website were really crawled.While the speculation about search engine indexing process may continue, here is a theory, based on experience, research and clues, about how they may be going about indexing 8 to 10 billion web pages even so often or the reason why there is a delay in showing up newly added pages in their index. This discussion is centered around Google, but we believe that most popular search engines like Yahoo and MSN follow a similar pattern.

  • Google runs from about 10 Internet Data Centers (IDCs), each having 1000 to 2000 Pentium-3 or Pentium-4 servers running Linux OS.
  • Google has over 200 (some think ‘over 1000′) crawlers / bots scanning the web each day. These do not necessarily follow an exclusive pattern, which means different crawlers may visit the same site on the same day, not knowing other crawlers have been there before. This is what probably gives a ‘daily visit’ record in your traffic log reports, keeping web masters very happy about their frequent visits.
  • Some crawlers’ jobs are only to grab new URLs (lets call them ‘URL Grabbers’ for convenience) - The URL grabbers grab links & URLs they detects on various websites (including links pointing to your site) and old/new URL’s it detects on your site. They also capture the ‘date stamp’ of files when they visit your website, so that they can identify ‘new content’ or ‘updated content’ pages. The URL grabbers respect your robots.txt file & Robots Meta Tags so that they can include / exclude URLs you want / do not want indexed. (Note: same URL with different session IDs are recorded as different ‘unique’ URLs. For this reason, session ID’s are best avoided, otherwise they can be misled as duplicate content. The URL grabbers spend very little time & bandwidth on your website, since their job is rather simple. However, just so you know, they need to scan 8 to 10 Billion URLs on the web each month. Not a petty job in itself, even for 1000 crawlers.

Continue Reading…

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blogmarks
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Ultimate Keywords Selection - An In-Depth Guide

 

 

When beginning a Search Engine Optimization campaign, there are a few basic steps that every SEO knows to take before they begin. The first is always to build a keyword list of which there are varying methods of doing so. The right methods will aid you in creating and supporting a site-wide SEO strategy. The wrong methods will run you in circles, wondering what went wrong.It is the intent of this article to teach an effective method of keyword selection that will enable you to land more keywords on the first page with less work.

Getting Started: Know the Site

To create a great keyword list, you will need to know your website backwards and forwards. You should know what the site features, and just as importantly, you should know what it doesn’t feature.

The first step is to brainstorm a list of somewhat generic keywords. For example, if you are a shoe store in Poughkeepsie, the temptation will arise to try and rank number 1 for the term “shoes.” Well, that’s a start, but ranking for the word “shoes” is probably aiming a little too high for a mom and pop shop in Upstate New York, which is why it’s very important that you know the site well enough to come up with a good list of pseudo-generic “modifiers” for your keyword:

Continue Reading…

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blogmarks
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Ultimate 100 SEO Tips

 

1. Write and submit articles. It is a classic, but it works. This will be indefinite traffic stuck in the search engines for you.

2. Write quality unique articles, not articles that are rehashed or provide no insight to readers, which is a huge problem these days. ..

3. Write and submit press releases, think prweb after you do one.

4. Write and ping blog entries. Always make sure to link back to your website with your blog posts. Try making multiple blogs and have them all link back to one main site.

5. Make sure your website is listed in DMOZ: http://dmoz.org/. .

6. Advertise your website in the appropriate categories at Craigslist. Try posting your ads in the most populated cities in the world.

7. If a niche related forum that you frequently visit allows signatures, then make sure to add your website url in there.

8. Make sure to view related products on Amazon.com. You can try and take some customers from your competitors here by providing your own url if the product is similar. Review websites in your niche on Alexa to try to take some of their traffic by including a reference back to your site.

9. Review some related products on epinion.

10. If you purchase a product that you actually like, then feel free to give an individual respect when respect is due and leave a testimonial. You should be able to get some traffic from that website if your testimonial is left with a url.

11. Whenever you send an email to someone, always add your website url as a signature.

12. Keep updating content on your websites/blogs… try at least once per week.

13. Tag blog posts at social bookmarking sites, especially at http://del.icio.us/. .

14. Add photos to your blog with appropriate keywords.

15. Tag blog photos at Flickr.

16. Politely ask your readers to subscribe to your rss feeds.

17. Try coining your own term. Might want to trademark it if you smell that it will become popular.

18. Encourage readers to comment on your blogs.

19. Include translation for your websites/blogs, especially in Chinese.

20. Do not be boring; write about something that a wide select of people would want to know about.

Continue Reading…

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blogmarks
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Basic Components of Struts

This article describes the basic components of Struts and it is the continuation of the Introduction To Struts. libraries for working with view technologies other than JSP, and so on.

The Struts framework is a rich collection of Java libraries and can be broken down into the following major pieces:

  • Base framework
  • JSP tag libraries
  • Tiles plugin
  • Validator plugin

A brief description of each follows.

Base Framework
The base framework provides the core MVC functionality and is comprised of the building blocks for your application. At the foundation of the base framework is the Controller servlet: ActionServlet. The rest of the base framework is comprised of base classes that your application will extend and several utility classes. Most prominent among the base classes are the Action and ActionForm classes. These two classes are used extensively in all Struts applications. Action classes are used by ActionServlet to process specific requests. ActionForm classes are used to capture data from HTML forms and to be a conduit of data back to the View layer for page generation.

JSP Tag Libraries
Struts comes packaged with several JSP tag libraries for assisting with programming the View logic in JSPs. JSP tag libraries enable JSP authors to use HTML-like tags to represent functionality that is defined by a Java class.

Following is a listing of the libraries and their purpose:

  • HTML Used to generate HTML forms that interact with the Struts APIs.
  • Bean Used to work with Java bean objects in JSPs, such as accessing bean values.
  • Logic Used to cleanly implement simple conditional logic in JSPs.
  • Nested Used to allow arbitrary levels of nesting of the HTML, Bean, and Logic tags that otherwise do not work.

Tiles Plugin
Struts comes packaged with the Tiles subframework. Tiles is a rich JSP templating framework that facilitates the reuse of presentation (HTML) code. With Tiles, JSP pages can be broken up into individual ’tiles’ or pieces and then glued together to create one cohesive page. Similar to the design principles that the core Struts framework is built on, Tiles provides excellent reuse of View code. As of Struts 1.1, Tiles is part of and packaged with the core Struts download. Prior to Struts 1.1, Tiles was a third-party add-on, but has since been contributed to the project and is now more tightly integrated.

Validator Plugin
Struts comes packaged, as of version 1.1, with the Validator subframework for performing data validation. Validator provides a rich framework for performing data validation on both the server side and client side (browser). Each validation is configured in an outside XML file so that validations can easily be added to and removed from an application declaratively versus being hard-coded into the application. Similar to Tiles, prior to Struts 1.1, Validator was a third-party add-on, but has since been included in the project and is more tightly integrated.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blogmarks
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

What is Model-View-Controller (MVC) Architecture?

Model-View-Controller is mini architecture and design pattern used for dividing application components into three different categories Model, View and the Controller. Components of the MVC architecture have unique responsibility and each component is independent of the other component. Changes in one component will have no or less impact on other component. Responsibilities of the components are:

Model View Controller Diagram

Model: Model is responsible for providing the data from the database and saving the data into the data store. All the business logic implemented in the Model. Data entered by the user through View are checked in the model before saving into the database. Data access, Data validation and the data saving logic are part of Model.
View: View represents the user view of the application and is responsible for taking the input from the user, dispatching the request to the controller and then receiving response from the controller and displaying the result to the user. HTML, JSPs, Custom Tag Libraries and Resources files are the part of view component.
Controller: Controller is intermediary between Model and View. Controller is responsible for receiving the request from client. Once request is received from client it executes the appropriate business logic from the Model and then produces the output to the user using the View component. ActionServlet, Action, ActionForm and struts-config.xml are the part of Controller.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blogmarks
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Bulletproof Internet Marketing Plan

  1. Introduction
  2. Directory Submission
  3. Forum Marketing
  4. Yellow Pages
  5. Classifieds
  6. Article Marketing
  7. Social Media Marketing
  8. Blog Marketing
  9. Video Marketing
  10. e-Groups Marketing (Optional)
  11. IM Marketing (Optional)

1. Introduction
Internet Marketing is somewhat different than ordinary marketing and Search Engine Optimization or Search Engine Marketing thuough it supports the SEO / SEM Process and generate traffic.
Internet Marketing involves the utilization of all the traffic grabbing & social discussion places to drive traffic. It uses all mediums & tools that are people using on the Internet for their purpose. When you marketing plan is executing, people will land on your website and see the content as well desing. So you may consider the following for an effective Internet Marketing.

Pre-requisite: A well SEO developed website, perfect SEO on page. Design and content would have no issues. While marketing to Internet, you may experience the global trends, different cultures & different language speaking audience. You would follow the followings at least
Continue Reading…

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blogmarks
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

Java: Connecting to SQL Server 2000 using JDBC

Overview
Cross-platform Java Database Connectivity JDBC implementations are commonly used to connect Java programs to any of the major databases available on the market today. There are several possibilities of connecting programs to databases. We’ll focus on JDBC here and are going to point out one of the key advantages: there is no client side software installation required.

More exactly, we do not need the Microsoft SQL Server client side installation. JDBC works just over your network. You may take a program to any of your PCs and run it directly from your CD. This works, of course, not only because we use JDBC, but also because we use Java.

Example:
Microsoft SQL Server is located on the machine in the centre of the following figure. Note that SQL Server 2000 is only running on Microsoft’s Server Operating Systems. Our test environment includes the following hardware: Windows 2000 Professional, SUN Solaris 8 and Redhat Linux 7.2.

Continue Reading…

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blogmarks
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb