Tuesday, May 26, 2009
How To Embeded Flash in Java Desktop App
To use Flash SWT Plugin, download com.docuverse.swt.flash-0.4.zip and extract it somewhere on local disk. Now our eclipse flash project need to add atleast two external jars e.g. flash.jar[from where we just extract the zip] and swt.jar and now we are ready to code.
THE SOURCE
To play swf file, all we need is FlashPlayer object and activate it that all. it'll look like this.
import com.docuverse.swt.flash.FlashPlayer;
public class SWTPlayer {
....
private void run() {
// TODO Auto-generated method stub
Display display = new Display();
Shell shell = new Shell(display);
FlashPlayer player = new FlashPlayer(shell);
player.loadMovie(0, "yourflashfile.swf");
player.setSize(550, 400);
player.activate();
shell.setSize(550, 400);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
How To: Test Your Antivirus
Have you ever wondered if your anti virus is working properly? I haven’t had a virus alarm for a while now so I started doubting if my antivirus
was working properly or was just hogging my system memory and wasting my time download updates and definitions for nothing.So I decided to find a way to test it, but how could I test my antivirus without risking damaging my system? Why creating my own little virus of course.I’ll show you how to make a virus using notepad that will test the ability and efficiency of your current antivirus without causing any damage to your computer even if you don’t have an anti virus nothing will happen.Lets get to it:
1) Open a new notepad document
2) Type the code below into the notepad file.
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
3) Save the notepad file as FakeVirus.com or whatever you want, To comfortably find the file, I suggest placing it in the Desktop.To save a file in .com format all you need to do is change the “Save as type:” to All Files and then just enter FakeVirus.com in the “File name:” section and click Save.
4) Run the FakeVirus.com file to test your computers efficiency. If your anti virus software
doesn’t give you a warning or alert, I suggest changing your AntiVirus immediately as your current one doesn’t work properly.Check out this article for a few good free antivirus softwares.
5) After your done with the file just delete it and empty the trash, remember this fake virus won’t affect your computer in any way.
Enjoy.
Monday, May 25, 2009
Dos Commands
Let's take a look at some important DOS commands available in Windows XP. These commands/tools must be run from the command prompt of the cmd.exe command interpreter.
To run cmd.exe, click Start, click Run, type cmd and click OK. You will then see a black window similar to the one above.
Tip: Wherever you have to type the path to a folder after the command, just drag the file or folder from Windows Explorer into the command window instead of typing the whole path.
Assoc: Displays or modifies file name extension associations. Used without parameters, assoc displays a list of all the current file name extension associations.
At: Schedules commands and programs to run on a computer at a specified time and date. You can use at only when the Schedule service is running. Used without parameters, at lists scheduled commands.
Attrib: Displays, sets, or removes the read-only, archive, system, and hidden attributes assigned to files or directories. Used without parameters, attrib displays attributes of all files in the current directory.
Comp: Compares the contents of two files or sets of files byte by byte. Comp can compare files on the same drive or on different drives, and in the same directory or in different directories. When comp compares the files, it displays their locations and file names. Used without parameters, comp prompts you to enter the files to compare.
Copy: Copies one or more files from one location to another.
Cprofile: Cleans specified profiles of wasted space and, if user-specific file associations are disabled, removes these associations from the registry. Profiles that are currently in use are not modified.
Defrag: Locates and consolidates fragmented boot files, data files, and folders on local volumes.
Driverquery: Displays a list of all installed device drivers and their properties.
Fc: Compares two files and displays the differences between them. Fc can even resynchronize files if there is a mismatch.
Find: Searches for a specific string of text in a file or files. After searching the specified file or files, find displays any lines of text that contain the specified string.
Getmac: Returns the media access control (MAC) address and list of network protocols associated with each address for all network cards in each computer, either locally or across a network.
Help: Provides online information about system commands (that is, non-network commands). Used without parameters, help lists and briefly describes every system command.
Helpctr: Starts Help and Support Center. Used without parameters, helpctr displays the Help and Support Center home page.
Hostname: Displays the host name portion of the full computer name of the computer.
Ipconfig: Displays all current TCP/IP network configuration values and refreshes Dynamic Host Configuration Protocol (DHCP) and Domain Name System (DNS) settings. Used without parameters, ipconfig displays the IP address, subnet mask, and default gateway for all adapters.
Irftp: Sends files over an infrared link. Used without parameters or used with /s, irftp opens the Wireless Link dialog box, where you can select the files that you want to send without using the command line.
Lpq: Displays the status of a print queue on a computer running Line Printer Daemon (LPD). Used without parameters, lpq displays command-line help for the lpq command.
Mmc: Opens Microsoft Management Console (MMC). Using the mmc command-line options, you can open a specific MMC console, open MMC in author mode, or specify that the 32-bit or 64-bit version of MMC is opened.
More: Generally used along with other commands, displays one screen of output at a time.
Move: More convenient than copy-paste. Moves one or more files from one directory to the specified directory. For example, you have some Excel files having their names start with "MonthlyReport" in your My Documents folder which you want to move to a separate folder. Using the Windows XP Explorer, you would have to manually select every single file and then use cut-paste. Using the move command to perform the same task is much simpler and easier. Type the following command and hit enter:
move MonthlyReport*.xls c:\MonthlyReports\
Msinfo32: Displays a comprehensive view of your hardware, system components, and software environment.
Netstat: This command is very useful to diagnose slow internet connections. It displays active TCP connections, ports on which the computer is listening, Ethernet statistics, the IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols). Used without parameters, netstat displays active TCP connections.
Openfiles: Queries or displays open files. Also queries, displays, or disconnects files opened by network users.
Ping: Verifies IP-level connectivity to another TCP/IP computer by sending Internet Control Message Protocol (ICMP) Echo Request messages. The receipt of corresponding Echo Reply messages are displayed, along with round-trip times. Ping is the primary TCP/IP command used to troubleshoot connectivity, reachability, and name resolution. Used without parameters, ping displays help.
Recover: Recovers readable information from a bad or defective disk.
Runas: Allows a user to run specific tools and programs with different permissions than the user's current logon provides.
Shutdown: Allows you to shut down or restart a local or remote computer. Used without parameters, shutdown will logoff the current user.
Start: Starts a separate Command Prompt window to run a specified program or command. Used without parameters, start opens a second command prompt window.
Systeminfo: Displays detailed configuration information about a computer and its operating system, including operating system configuration, security information, product ID, and hardware properties, such as RAM, disk space, and network cards.
Taskkill: Ends one or more tasks or processes. Processes can be killed by process ID or image name.
Tasklist: Displays a list of applications and services with their Process ID (PID) for all tasks running on either a local or a remote computer.
Tree: Graphically displays the directory structure of a path or of the disk in a drive.
Ver: Displays the Windows XP version number.
Vol: Displays the disk volume label and serial number, if they exist. A serial number is displayed for a disk formatted with MS-DOS version 4.0 or later.
W32tm: A tool used to diagnose problems occurring with Windows Time.
Xcopy: Copies files and directories, including subdirectories.
You can find the complete list of command prompt commands for Windows XP, Syntax, Parameters & Examples here.
Wednesday, May 20, 2009
How To Change Network IP From Batch File

2. Now copy the code that is given below
netsh interface ip set address name="Local Area Connection" source=static addr=192.168.1.100 mask=255.255.255.0netsh interface ip set address name="Local Area Connection" gateway=192.168.1.1 gwmetric=0netsh interface ip set dns name="Local Area Connection" source=static addr=208.67.222.222netsh interface ip add dns name = "Local Area Connection" addr =208.67.220.220
The relevant IP’s are illustrated in the screenshot below, the IP’s that are illustrated are only examples:
3. Now that you have copied the code, paste this in the Notepad. Enter the IP’s as per your requirements and save the file with the extension *.bat
[eminimall]
4. Your batch file is now ready for execution, now double click the batch file that you just created and you will find your network settings configured in a few seconds.
5. Create another batch file using the similar procedure, in this batch file you enter the IP’s that are relevant to your other location.
6. Now you should be having two batch files one for your office network and the other for your home network.
I guess by using this method your life would ease a bit. :) If you have better method then do let me know.
Tuesday, May 19, 2009
Free Download Sites
http://www.download3000.com/

Downlad Free Softwares From
http://www.soft32.com/

Downlad Free Softwares From
http://www.softpedia.com/

Downlad Free Softwares From
http://www.download3k.com/

Downlad Free Softwares From
http://download.cnet.com/windows/
Downlad Free Softwares From
http://www.freedownloadscenter.com/

Downlad Free Softwares From
http://www.topsofts.com/

Downlad Free Softwares From
http://www.freewarefiles.com/

Downlad Free Softwares From
http://100-downloads.com/
Sunday, May 17, 2009
How To Set The Line Number In TextArea
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
<style type="text/css">
#container
{
width: 20px;
float: left;
color: Gray;
font-family: Courier New;
font-size: 14px;
overflow: hidden;
height: 85px;
position: relative;
top: 5px;
}
#divlines
{
position: absolute;
}
#text1
{
overflow-x: scroll;
height: 99px;
font-family: Courier New;
font-size: 14px;
}
</style>
</head>
<body>
<div id="container">
<div id="divlines">
</div>
</div>
<textarea id="text1" cols="50" wrap="off">first
second
third
fourth
fifth
sixth
seventh
eighth
ninth</textarea>
<script type="text/javascript">
var lines = document.getElementById("divlines");
var txtArea = document.getElementById("text1");
window.onload = function() {
refreshlines();
txtArea.onscroll = function () {
lines.style.top = -(txtArea.scrollTop) + "px";
return true;
}
txtArea.onkeyup = function () {
refreshlines();
return true;
}
}
function refreshlines() {
var nLines = txtArea.value.split("\n").length;
lines.innerHTML = ""
for (i=1; i<=nLines; i++) {
lines.innerHTML = lines.innerHTML + i + "." + "<br />";
}
lines.style.top = -(txtArea.scrollTop) + "px";
}
</script>
</body>
</html>
How To Set The Foucs On Last Row in TextArea
window.onload=function WindowLoad(event)
{
var objControl=document.forms["FrmTestScroll"].elements["textarea1"];
objControl.scrollTop = objControl.scrollHeight;
}
</script>
<form id="FrmTestScroll">
<textarea rows="3" cols="10" name="textarea1">lots of text goes here. it would be on more than one line.</textarea>
</form>
Sunday, May 10, 2009
Insertion Sort Implementation in Java
Simple to implement
Efficient on (quite) small data sets
Efficient on data sets which are already substantially sorted
More efficient in practice than most other simple O(n2) algorithms such as selection sort or bubble sort: the average time is n2/4 and it is linear in the best case
Stable (does not change the relative order of elements with equal keys)
In-place (only requires a constant amount O(1) of extra memory space)
It is an online algorithm, in that it can sort a list as it receives it.
In abstract terms, each iteration of an insertion sort removes an element from the input data, inserting it at the correct position in the already sorted list, until no elements are left in the input. The choice of which element to remove from the input is arbitrary and can be made using almost any choice algorithm.
/*** Simple insertion sort.* @param a an array of Comparable items.*/
public static void insertionSort( Comparable [ ] a )
{for( int p = 1; p < a.length; p++ )
{
Comparable tmp = a[ p ];int j = p;
for( ; j > 0 && tmp.compareTo( a[ j - 1 ] ) < 0; j-- )
a[ j ] = a[ j - 1 ];
a[ j ] = tmp;
}
}
BinarySearch in Java
{
public static final int NOT_FOUND = -1;
/**
* Performs the standard binary search
* using two comparisons per level.
* @return index where item is found, or NOT_FOUND.
*/
public static int binarySearch( Comparable [ ] a, Comparable x )
{
int low = 0;
int high = a.length - 1;
int mid;
while( low <= high )
{
mid = ( low + high ) / 2;
if( a[ mid ].compareTo( x ) < 0 )
low = mid + 1;
else if( a[ mid ].compareTo( x ) > 0 )
high = mid - 1;
else
return mid;
}
return NOT_FOUND; // NOT_FOUND = -1
}
// Test program
public static void main( String [ ] args )
{
int SIZE = 8;
Comparable [ ] a = new Integer [ SIZE ];
for( int i = 0; i < SIZE; i++ )
a[ i ] = new Integer( i * 2 );
for( int i = 0; i < SIZE * 2; i++ )
System.out.println( "Found " + i + " at " +
binarySearch( a, new Integer( i ) ) );
}
}
Sunday, May 3, 2009
How To Increase Heap Size of Tomcat
2. find word "set JAVA_OPTS="
3. Replace find string with below string
set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties" -Xms1024m -Xmx1024m -XX:MaxPermSize=128m
