Like This Site? 
 
RSS Feed Follow Us 

on Twitter! Be Our Fan!

How to Create Graphs in Java?

Share this post!
 Vote this!

Java is one of the most common technologies in use on websites. It is a great language that allows web developers to create some fantastic features on websites. Many developers use Java to generate dynamic information from data stored on the website rather than rely on using static images and data.                                more...

Core Java Very basic Questions

Share this post!
 Vote this!

Java programming language is very vast programming language,even I must say each and every programming language is very vast.Understanding Java programming language and applying its concept needs the knowledge and skills of Java programming language.I have gone through various important questions during my ride to SCJP.So I have prepared a list of such important questions of Java programming language which will help you not only in understanding the topic but also If you are preparing for SCJP they will be helpful.         more...

How to Set Icons on Swing Buttons

Share this post!
 Vote this!

Swing Buttons provides many exclusive features that are not found in the Button class defined in the AWT package.Swing Buttons are the subclass of AbstractButton class,which extends JComponent.You can always associate an icon of your choice with a Swing Button.The Icons are set as program runs or set when some event is fired like button pressed.AbstractButton class contains many methods that allow you to control the behaviour of buttons,check boxes and Radio Buttons.There is the way you can set the icon on the swing button and it is through the JButton constructor.                more....

Starting and running Multiple Threads

Share this post!
 Vote this!

In the previous tutorials about Threads we have learnt about the basics of Threads,How to create a Thread and also how to start a Thread.So far we have learnt how to start a single Thread but in this tutorial we will learn about how we can start and run Multiple Threads

To start Multiple Threads we use Runnable interface method which is best one.So we will implement the Runnable interface in our class and use the instance of our class to start Threads.To start a Thread we simply need a method start() to begin all the Threads.           more...

Using Break as GOTO

Share this post!
 Vote this!

Break statement has following three uses:-

1.Terminate the execution sequence in switch.
2.Used to exit loops from anywhere.
3.Break used as form of GOTO.

GOTO statement as we know is not supported by Java.The reason being it provides control branching in unstructured and arbitrary manner.It is quite obvious from a C and C++ program that after reading through GOTO-ridden code is hard to understand the flow of program and also code is hard to maintain.                 more...

How to use Java command Line Arguments

Share this post!
 Vote this!

Whenever we need to pass information into our program during execution ,we can use command line arguments.The Command line arguments are actually the arguments of main() method and are of String Format.Basically command line arguments are those directly follow program's name on the command prompt.As I told earlier that are none other than simple main() programs arguments.All the command line arguments are stored in the form of String.So it is advised to change to required type like integer,char etc before using them in the main program.                    more...

Final,Finally and Finalize keyowrds in Java explained

Share this post!
 Vote this!

final, finally, and finalize are keywords (and a method) in Java that despite their common naming are used for completely different purposes. It seems that because of this very reason interviewers like to ask questions about the differences between final, finally and finalize. So, in order to get a better understanding on this issue, here's my brief explanation of the final and finally keywords, and the finally method, along with relevant examples:                more...

How to Create Your Own Objects in Java

Share this post!
 Vote this!

This tutorial WILL cover the basics of creating your own objects, good practices for creating objects and why using OOP over procedural oriented programming is much more efficient and better.

Why OOP?
Object's are one of the most powerful tools a programmer has, it allows the programmer to easily reuse code, create a data type for a specific task, and easily manage data without worrying about it changing or becoming stale through the use of encapsulation. Objects should be used whenever possible to save in development time and code needed to write. If you look at the Java API you'll see an almost endless list of objects to do just about any task you would want to do.  more...

Dijkstra's Algorithm Implementation in Java

Share this post!
 Vote this!

Dijkstra's Algorithm is a graph-search algorithm that finds the shortest path between two Vertices on a weighted Graph. For Dijkstra's algorithm, we assume that all distances are positive.

So how exactly does this algorithm work? Basically, we initialize all the distances to infinity, except for the root Vertex which is initialized to 0. We then traverse the Graph from the starting point towards the end point. When we hit a Node, we evaluate the cumulative distance to that Node, which means the distance recorded at the previous Node plus to the distance to the current Node. So if we have A-->B weighted at 5 and B-->C weighted at C, B would record the distance 5, and C would record the distance 8. The reason we initialize to infinity is that the first time we hit that Node, everything will be less than infinity so the first distance will be stored at that Node. more...

Java : Comparing string with the wild card pattern

Share this post!
 Vote this!

Have you ever searched for files and folders in Windows operating system? Generally most of the users try to search various .doc files, .pdf files etc. We generally search by giving *.doc or *.pdf in the text box of the search window of the windows OS. Of course windows OS provides some other more specific search utilities. However this kind of search is used in many applications. If an application provides this kind of facility it is considered as the best feature of that application.

Technicalities

It is always important for an application how the user is going to provide a search condition. All kinds of search conditions are not always feasible. Generally It has been universally endorsed that a user can search based upon certain specifications. As far this specification is concerned, we generally search by providing wild card characters. The wild card characters are * and ? . There is a concept behind these characters. I hope you know about it. This kind of search specification is recurrent in various applications.  more...

Java : Splitting a huge file in to equal parts

Share this post!
 Vote this!

Suppose you don't know how many records are in a dataset, but you want to divide the records as equal as possible among the output datasets. We can split a file into equal number parts by using ICETOOL with a small keyword SPLIT / SPLITBY. The all output files will have same number of records. The below code split the file into three equal parts.   more...

Adding and using child windows in a Java GUI in an MVC architecture

Share this post!
 Vote this!

Adding and using child windows in a Java GUI in an MVC architecture

Summary: This tutorial provides a working example of how to create an Model-View-Controller (MVC) Java GUI using Swing, including the use of two child windows that share data with the main GUI and among themselves.

Prerequisites:
(1) An understanding of the Model-View-Controller (MVC) architecture or pattern. If you are not familiar with the MVC architecture, I recommend you study the example at:  more...

Common problems and their solutions for Java newbies on Microsoft Windows

Share this post!
 Vote this!

Compiler Problems

1. 'javac' is not recognized as an internal or external command, operable program or batch file

If you receive this error, it means that Windows is not able to find the compiler (javac). Here's one way to tell Windows where to find javac. Set the PATH as follows on Microsoft Windows:

1. Click Start -> Control Panel -> System on Windows XP or Start -> Settings -> Control Panel -> System on Windows 2000.
2. Click Advanced -> Environment Variables.
3. Add the location of bin folder of JDK installation for PATH in User Variables and System Variables. A typical value for PATH is:  more...

Java Code For Screenshot capturing and saving in local System

Share this post!
 Vote this!

This Code snippet is used to capture Screenshot automatically and save it.

The below code performs the function of taking screenshots automatically making use of the class java.awt.Robot .The package java.awt contains all of the classes for creating user interfaces and for painting graphics and images.

The class java.awt.Toolkit helps in obtaining the screen size of the page and the class java.awt.Rectangle creates a rectangle with the same dimensions of the page.

The class java.awt.image.BufferedImage helps in creating a image containing pixels and colour similar to page and this does not involve the mouse cursor.

The taken screen shot can be stored in any mode depending on user's preference.

Thus this code automates the procedure of obtaining screenshots so the user may find it easier to know the status of the page .   more...

Debugging Java applications using ProbeVue

Share this post!
 Vote this!

Introduction
Introduced in AIX 6.1, ProbeVue is a dynamic tracing facility. Initially, it was designed to dynamically trace C applications and system calls in the system. Over time, it now provides support for probing Java™ applications and support for taking live dump and base system calls. This article covers Java support of ProbeVue.
ProbeVue has the following features:
  • Trace hooks do not have to be pre-compiled as part of your source code.
  • ProbeVue works on 32/64-bit kernel and applications without any modification.
  • Trace hooks do not exist, until they are placed via ProbeVue.
  • Trace data captured as part of the tracing actions are available for viewing immediately and can be displayed as terminal output or saved to a file for later viewing.
  • Trace hooks can be applied at the entry or exit of any function (currently exit probe point is supported for system calls only).  more...

5 things you didn't know about everyday Java tools

Share this post!
 Vote this!

Some Java™ tools defy categorization and are frequently collected under the rubric of "things that work." This installment of 5 things offers up a collection of tools you'll be glad to have, even if you end up storing them in your kitchen drawer.
The Java platform is full of "bits of string" — useful command-line tools and libraries that most Java developers will never even know about, let alone use.Many of them don't fit neatly into any of the programming categories I've covered so far in the 5 things series, but try them out anyway: some could still earn a place in your virtual kitchen drawer.

1. StAX

Develop skills on this topic

This content is part of a progressive knowledge path for advancing your skills. See Become a Java developer
When XML first appeared on most Java developers' radar, back around the turn of the millennium, there were two basic approaches to parsing XML files. The SAX parser is essentially a giant state machine of events fired back at the developer via a series of callback methods.  more...

5 things you didn't know about enhancing Swing

Share this post!
 Vote this!

Swing is an older toolkit, developed long before the advent of beautiful user interfaces, and it's missing some of the components you might need for building rich UIs. Fortunately, open source projects like Substance, SwingX, and the Java™ Look-and-Feel Graphics Repository make up the difference. Author Steven Haines shows you how to painlessly add tree tables, syntax highlighting, and more to your Swing UIs.
User interface design and development have changed a lot in recent years, and some would say the Java platform hasn't really kept up. Swing, released in 1997, is still the standard toolkit for building user interfaces into the JVM. On the upside, it's a familiar standard and easy to work with; on the downside, it's missing some features that have become common to rich UI design.  more...

Creating a Binary Clock in Java

Share this post!
 Vote this!

Table of Content:

  • What is a Binary Clock and How To read it?
  • Getting started
  • Creating JFrame and other needed things
  • Creating the "Clock"-Class
  • Painting the white ovals on the Canvas
  • Painting the Time on the Canvas
  • Decimal to Binary Algorithm
  • Optimizing the Clock
  • The End  more...

Using Java Utilities Package

Share this post!
 Vote this!

The java.util package has a number of utility classes

Vector class :  create array-like objects that can grow and shrink dynamically 
Stack class offers conventional stack operations push and pop along with several others
Dictionary class gives us the framework for storing keyed data in tables and retrieving the data 
Hashtable class a technique for rapidly storing and retrieving information from tables
Properties class enables us to create persistent hash tables i.e hashtables that can be written and read from a file 
Random class a collection of rendom number capabilities  more...

Complete Java Networking Explained with Examples

Share this post!
 Vote this!

In Java, networking is performed using Transmission Control Protocol/Internet Protocol (TCP/IP) or the User Datagram Protocol (UDP).

Java provides a low-level control on the connection, allowing you to customize it according to your requirements. The package containing networking classes, called java.net, is shipped as part of the Java Development Kit (JDK). In Java, TCP connections are established using sockets and server sockets. These connections allow you to send and receive data to a Web Site. On the other hand, broadcast messages known as datagrams use the UDP. Datagram’s are encapsulated in a datagram packet and sent using a datagram socket. URLs can be created and modified using the URL class methods of Java.

Socket Overview

A socket forms the interface between the protocol and client for communication. A Java socket forms the base for data transmission between two computers using TCP/IP. The socket specifies the site address and the connection port. When packets reach a client or server, they are routed to the destination port specified in packet header.  more...