Wednesday, May 8, 2013

Streaming log or Tail log using Notepad++

Notepad++ has the feature to update the file/log silently like "tail -f" in linux.

1. Select the Setting -> Preferences..



2. In the MISC tap select "Update silently" and "Scroll to the last line after update" option under "File Status Auto-Detection" part.


Other Alternative windows applications



Monday, May 6, 2013

Adjust LCD brightness in ubuntu in command line

1. Find the brightness range for your laptop

cat /sys/class/backlight/intel_backlight/brightness 

2. Set the brightness value

echo 1000 |sudo tee /sys/class/backlight/intel_backlight/brightness 

Thursday, May 2, 2013

Install oracle JDK in Ubuntu


Oracle retired the Operating System Distributor's License for Java, meaning that Canonical could no longer include the JDK or JRE in their APT repositories. This means no more "sudo apt-get install sun-java-whatever"

New Ubuntu installation comes with an open source implementation of Java SE installed, called OpenJDK (Open Java Development Kit), which is not compatible with applications written in Oracle Java.

Following are the steps to install Oracle JDK into Ubuntu

1. Download JDK package in http://www.oracle.com/technetwork/java/javase/downloads/index.html


for Linux x86 (32-bit) : jdk-7u21-linux-i586.tar.gz
for Linux (64-bit) : jdk-7u21-linux-x64.tar.gz

2. Extract the package

tar -xf jdk-7u21-linux-i586.tar.gz

This will extract and create a jdk folder at your current path.

3. Create a location to keep your new JDK . I prefer and usually use /usr/lib/jvm/
You may need root permission to create the /usr/lib/jvm (hence use sudo).

sudo mkdir /usr/lib/jvm

4. Move the extracted jdk folder to /usr/lib/jvm/

sudo mv jdk1.7.0_21 /usr/lib/jvm/

5. Now we have to setup our system to use refer to our new jdk

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_21/bin/java" 1 

sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_21/bin/javac" 1 


sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0_21/bin/javaws" 1


6. JAVA_HOME environment variable

vi /etc/bash.bashrc

 then add following line in endof the file

JAVA_HOME=/usr/lib/jvm/jdk1.7.0_21
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH


7 . All done.
When you reboot, try running the following:

$ echo $JAVA_HOME
/usr/lib/jvm/jdk1.7.0_21
 echo $PATH
usr/lib/jvm/jdk1.7.0_21 /bin



Thursday, April 25, 2013

Install Ubuntu in VirtualBox

1.Download and install oracle virtual box 
https://www.virtualbox.org/wiki/Downloads

2. Download ubuntu iso from ubuntu website 
http://www.ubuntu.com/download/desktop

3. Open Oracle virtual box and click "New"

4. Select the memory size 

5. Select the " Create a virtual hard drive now" option


6. Select Hard drive file type


7. Select "Dynamically allocated" option for storage 

8. Select the virtual disk size


9. Double click the newly created "ubuntu" label in left side


10. Select the folder icon as show below


11. Select the downloaded Ubuntu iso file


 12. Click start button as below 


 13. Install the Ubuntu 






Thursday, January 13, 2011

How to move Distribution database to a different location (MSSQL 2005/2008)

-->
1. Preparation
a. Stop Log Reader Agent


b. Stop Distribution Agent




c. Backup Distribution database
2. Check Distribution database Status
SELECT name, physical_name
FROM sys.master_files
where database_id = db_id('distribution')
3. Modify Distribution database files location
Alter database distribution modify file (name = distribution, filename = ‘New Location\distribution.MDF')
Alter database distribution modify file (name = distribution_log, filename = 'New Location \distribution.LDF')
4. Stop SQL SERVER service (NOTE: SQL AGENT SERVICE WILL STOP TOO)
5. Move old Distribution database files to NEW Location
a. MDF file
b. LDF file
6. Start SQL SERVER service
7. Start SQL AGENT service
8. Check Distribution database Status
SELECT name, physical_name
FROM sys.master_files
where database_id = db_id('distribution')
9. Start Distribution Agent service
10. Start Log Reader Agent service
Note:Make sure sql service agent has permission to access the new location

Wednesday, November 4, 2009

Grab and Drag image into JScrollpane

Following code helps you to scrolling the image by dragging mouse on it.

import
java.awt.Container;
import java.awt.Cursor;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
import javax.swing.event.MouseInputAdapter;

public class GrabAndDragDemo extends JFrame {
public GrabAndDragDemo() {
super("Grab and drag Demo");
ImageIcon ii = new ImageIcon("largeJava2sLogo.jpg");
JScrollPane jsp = new JScrollPane(new GrabAndScrollLabel(ii));
getContentPane().add(jsp);
setSize(300, 250);
setVisible(true);

WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
addWindowListener(l);
}

public static void main(String[] args) {
new GrabAndDragDemo();
}
}

class GrabAndScrollLabel extends JLabel {
public GrabAndScrollLabel(ImageIcon i) {
super(i);

MouseInputAdapter mia = new MouseInputAdapter() {
int xDiff, yDiff;

boolean isDragging;

Container c;

public void mouseDragged(MouseEvent e) {
c = GrabAndScrollLabel.this.getParent();
if (c instanceof JViewport) {
JViewport jv = (JViewport) c;
Point p = jv.getViewPosition();
int newX = p.x - (e.getX() - xDiff);
int newY = p.y - (e.getY() - yDiff);

int maxX = GrabAndScrollLabel.this.getWidth()
- jv.getWidth();
int maxY = GrabAndScrollLabel.this.getHeight()
- jv.getHeight();
if (newX < 0)
newX = 0;
if (newX > maxX)
newX = maxX;
if (newY < 0)
newY = 0;
if (newY > maxY)
newY = maxY;

jv.setViewPosition(new Point(newX, newY));
}
}

public void mousePressed(MouseEvent e) {
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
xDiff = e.getX();
yDiff = e.getY();
}

public void mouseReleased(MouseEvent e) {
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
};
addMouseMotionListener(mia);
addMouseListener(mia);
}
}


If your JScrollPane which contains the Jpanel where you render the image , simply
addMouseMotionListener(mia);
addMouseListener(mia);

add these codes to your JPanel.

Thursday, October 29, 2009

Create an executable JAR file using eclipse


  1. Right click on your project
  2. Select export from the context menu


3. Select the Runnable JAR file
4.Provide the destination path and launch configuration as mail class of the programme