maven - pom.xml define properties constants

Define :
    <properties>
        <my_Constant_String>com.gt.App</my_Constant_String>
    </properties>
Use :

 <some_property_tag>${my_Constant_String}</some_property_tag>

screen logger - capture screen periodically and save to folder - java

Screen Capture Logger Java Application : Capture screen in fixed interval and save jpeg image to a folder.
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

public class ScreenLogger {
    private static final String saveLocation = "c:\\logs\\";
    private static final int timeInterval = 1000 * 30;
    private static Rectangle rect;
    private static Robot robot;

    public static void main(String[] args) throws Exception {
        init();
        new Thread(new CaptureThread()).start();
    }

J2ME Bluetooth discover connect send read message

Bluetooth communication - discover (by both server and client), connect to ad hoc network, send, receive message in J2ME java code.
This working java source code was used in our project  BlueChess- two player chess game over bluetooth adhoc connection
Code:
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.ServiceRecord;
import javax.bluetooth.UUID;
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.StreamConnectionNotifier;

public class BtCommunication {

    private StreamConnectionNotifier scn=null;
    private DiscoveryAgent mDiscoveryAgent=null;
    private StreamConnection conn = null;
    private InputStream inputStream=null;

Java:opening a folder in windows explorer

opening a directory using start utility in windows

String cmd = "cmd.exe /c start ";
String file = "c:\\";
Runtime.getRuntime().exec(cmd + file);

Creating DSL / PPPOE Connection in UBUNTU

I have internet connection (worldlink-512kbps, cable net) shared with landowner and flatmates through wireless router. I recently created a PPPOE (Point to Point Protocol Over Ethernet) dial-up connection on my laptop to use whole bandwidth during load-shedding.

Creating DSL connection in Ubuntu is extremely easy.

Create, configure maven project in eclipse - example tutorial

In this post, the followings are covered :
  • Download and Install maven in windows:
  • Add M2_REPO classpath variable in eclipse 
  • Generate Java/Web Project  with maven and import in eclipse
  • Add another dependency from web repository
  • Add custom or 3rd party library manually into repository:
  • Benefits of using MAVEN :

Reading contents of unix ext partitions from windows

How to read / browse / copy files from linux ext partitions from windows?

Do you ever want to copy files from your unix ext partition from windows?
Ext2Explore is solution.
It supports ext2, ext3, ext4 partitions. and easy to use as it provides GUI like an file explorer.
This software is compatible with windows XP SP3 and higher.
Download it from SourceForge.net
You need to run this program as an Administer option.

Most Popular English Movies


Here is the list of best and popular movies that I have watched.
They are definitely good : inspiring and entertaining.
  1. A beautiful mind
  2. The Pursuit of Happiness
  3. Atonement
  4. The Notebook
  5. Casablanca
  6. Hill has eyes
  7. Stuck
  8. 8 belows
  9. Alive
  10. Awakenings
  11. Basketball diaries
  12. The Motorcycle Diaries (2004)
  13. Before Sunrise (1995)
  14. Before Sunset (2004)

Drawing Chess Game Board in Java - Source Code

Source code for Chess Game Board in Java :


public class ChessGUI extends JFrame {
    private Board board;
    private ChessGUI() {
        board = new Board();
        setLayout(new FlowLayout());
        add(board);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
        pack();
    }

java read content of web page

The following example use easier method to read String from InputStream in Java. It uses java.util.Scanner. It will be easy/efficient to read shorter content by using this method.
Reading content of web URL:
System.out.println("Google\n" + new Scanner(new URL("http://google.com").openStream())
                                                    .useDelimiter("\\A").next());
Reading a text file :
System.out.println("TextFile\n"+new Scanner(new File("inputFile.txt"))
                                                    .useDelimiter("\\A").next());
The regex "\\A" here matches the beginning of input source. Scanner can work not only with an InputStream source, but with  anything that implements the new (JDK version >= 1.5) java.lang.Readable interface.