Click here to Skip to main content
11,638,881 members (69,058 online)
Click here to Skip to main content

Cool Java Programs

, 18 Jul 2011 CPOL 43.3K 1.1K 11
Rate this:
Please Sign up or sign in to vote.
These are Java Programs for typing on computer without physically typing, screen capture, AutoDownloader, etc.


This includes Java Programs for:

  1. Typing on computer without physically typing
  2. Screen capture
  3. Auto Downloader
  4. Listing all processes in task manager
  5. Obtaining and setting Clipboard data

Using the Code

1) Typing on Computer without Physically Typing

The first program opens an editor like Notepad where our program will start typing automatically. This is achieved by:


Now we make our program type in Notepad. For this, we use the Robot class:

Robot r=new Robot();

A starting delay of 2 secs is introduced so that Notepad gets a chance to open and our program writes in Notepad and not anywhere else.

After each letter, we introduced a delay of .5 sec so that it looks like someone is typing.

2) Screen Capture

For this also, we will make use of the Robot class:

Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
Robot robot = new Robot();
BufferedImage img = robot.createScreenCapture(new Rectangle(size));
File save_path=new File("screen.jpg");
ImageIO.write(img, "JPG", save_path);	 

Here Dimension gets your screen size and puts dimension in the size variable. createScreenCapture function takes a screenshot. ImageIO.write is responsible for writing the screenshot as a JPG file.

3) Auto Downloader

Here is a simple Java program to download a file with Java:

System.out.println("Enter the url to download from:");
BufferedReader input = new BufferedReader(new InputStreamReader(;
String site = input.readLine();
System.out.println("Enter filename");
BufferedReader input1 = new BufferedReader(new InputStreamReader(;
String filename = input.readLine(); in = new; fos = new; bout = new BufferedOutputStream(fos,1024);
byte[] data = new byte[1024];
int i=0;

Here, first you need to give the URL of file to download. Now you have to specify the name by which it will be saved like a .zip. Here in variable is used to read the data obtained from URL and then this data is written to your system with the help of bout.

4) Task Manager Processes

It is very easy to list all processes that are active in task manager. Just use this program:

String line;
Process p = Runtime.getRuntime().exec("tasklist.exe");
BufferedReader input =
                new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
	System.out.println(line); //<-- Parse data here.

Here tasklist.exe gives us all the running processes. We store all results inside a variable input from which we later list the result to output console.

5) ClipBoard Details

It is very easy to get and set clipboard data. Here is a sample:

Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
	String text = (String)t.getTransferData(DataFlavor.stringFlavor);
	System.out.println("Current ClipBoard data is:\n"+text);
	text="I changed clipboard text";
	StringSelection ss = new StringSelection(text);
	Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
	System.out.println("Changed ClipBoard data is:\n"+text);

This program first retrieves the current clipboard content, shows it and then changes it.

Points of Interest

The Robot class may also be used to get pixel information and can even simulate mouse click.

The Runtime.getRuntime.exec() gives the power to Java to execute Windows application directly.

The clipboard program can be enhanced further which can help you make a good desktop app.


  • 17th July, 2011: Initial version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
India India
I am a Java software developer. I like to make new software which can be really helpful to people. You may get in touch with me at

You may also be interested in...

Comments and Discussions

QuestionHow to run this? Pin
JDH12315-Jul-14 12:11
memberJDH12315-Jul-14 12:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150728.1 | Last Updated 18 Jul 2011
Article Copyright 2011 by csanuragjain
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid