Monday, May 20, 2013

Error: Could not find or load main class (Java)

Quick solution:

Run the file with -cp . <file_name>

java -cp . HelloWorld

Mind the spaces !  java [space] -cp [space] . [space] HelloWorld

Sunday, April 28, 2013

Killing the windows process using a simple batch file


To kill a process what we have to do  is to run this windows command  taskkill  /IM  /t /f

Where taskkill is the command to kill the process, /IM  is the image or process name, /t  to kill all the sub processes, and /f  to kill the process forcefully.

I am lazy to write all this in command prompt with Admin privileges  :)  That's why I have created a sample batch file where I just write the name of the process and it kills the process.

Create Batch File:

1. Open notepad and write this code


@ECHO OFF

set /p ProcessName= Enter Process Name To Kill: 

taskkill /IM "%ProcessName%" /t /f

2. Save this file as <any name>. bat . But don't save it as taskkill.bat

Execute batch file:
Double click to open this batch file and write the process name that you want to kill

exanple:

Enter Process Name To Kill : iexplore.exe

Monday, February 25, 2013

How to maximize the Windows Remote Desktop viewer

Suddenly  I started facing this issue that my Remote Desktop viewer is not maximizing. I don't know the root cause, may be some how the resolution of RDP viewer changed to less resolution. It is so annoying to work in the limited size !!! Always you have to scroll down/up to view properly.

The solution is very simple.

1. Open your Remote Desktop Connection dialog box (run -> mstsc).
2. There in the left hand down corner Click Options
3.  Now click the Display tab and pull the slider to max to get the Full Screen option

You are done ! Now connect.

Friday, February 8, 2013

How to create a Windows 7, Windows 8 bootable USB/Pendrive

There are lots of guidance you can get from google to make a bootable USBdrive. But be careful ! They can lead you to a corrupted OS or USB drive.

This procedure is safe and you can install Windows faster than discs and without any hassles.

Requirements:

1. USB Drive (Minimum 4GB)
2. Windows installation files. You can copy this files in your machine from the windows CD/DVD.

Procedure:

1. Go to Start menu > All programs > Accessories, right click on Command Prompt and select Run as
administrator.

2. Now type the following commands one by one
 
You will now enter into the DISKPART utility.
    i)  DISKPART 

Now note down the Disk number (eg: Disk 2) of your USB flash drive. In the below screenshot my Flash Drive Disk no is Disk 2.
    ii) LIST DISK

Select your USB disk
   iii) SELECT DISK 2

Clean the disk
   iv) CLEAN

Create a primary partition in the USB drive
   v) CREATE PARTITION PRIMARY

Now select the partition
   vi) SELECT PARTITION 1 

Make the partition as active

   vii) ACTIVE

Attention: This process can take almost an hour to format depending upon the size of the USB drive. Better right click on the USB drive and select NTFS and Quick format. And don't execute command no. viii)
   viii) FORMAT FS=NTFS





After completing FORMAT now Assign it and exit from DISKPART utility
   ix) ASSIGN
   x)  EXIT 



Now you'll again come back to C:\Windows\system32>. Don't close the Command prompt just minimize it.

3. Now the actual location of the Windows installer files could be a CD/DVD or it can be in your Local Disk)
I assume it is in CD/DVD and the drive then the path should look like F:\boot (Drive can be anything D, E as per your machine)
Or if it is in Local disk then I assume the path  looks like :   D:\<windows7 folder>\boot 

4.  Now again maximize the command prompt. and got to the \boot  folder location


     C:\Windows\system32> cd F:\boot
     F:\boot> bootsect.exe /NT60 G:

Where G: is your USB drive letter (in my case). We are actually updating the USB drive with the BOOTMGR. 


5. Now Copy the Windows installer files in the USB drive.


Your Bootable USB drive is now ready. From BIOS change the boot order to USB and install Windows.

Thursday, February 7, 2013

How to undo a sent mail from Gmail

Oooopss !!! sent a mail to wrong person ? Don't worry there is a option to undo the sent message within maximum 30 second. 
1. In your Gmail account click the gear icon  in the upper right, then select Settings
2. Select the 'Labs' tab and identify the labs you want to enable. Click the 'Enable' radio button to turn on a lab (Undo Send ) and click 'Save Changes' at the bottom of the page. Your page may refresh but after the refresh, the lab you just turned on will be available in Gmail.

You can also set the time to undo the sent message. Maximum is 30 second.

Delete .lock files faster than SVN commands


A lock file used to generate in the .svn directory if any fatal error occurs during any SVN operations.  So there can be thousands of directories and sub directories inside that. The .lck file will be generated in all the .svn folder for all the directories and sub directories.

You can simply use SVN GUI (right click on the parent folder and clean) or command line (svn cleanup) arguments to clean up the lock file. But if your code is very large i.e if number of nested directories and sub directories is huge then most of the time the cleanup process becomes unresponsive.

In windows simply open the parent directory from command prompt and delete the lock files by giving this command:

del /s lock

Where del is to delete the lock file and /s to delete all the lock file in the sub directories.

Actual location of static variables in Java


Static variable is allocated for the entire duration of program's execution, so neither stack nor heap are convenient for it. Static fields are initialized when a class is loaded and and are discarded when the class loader for that class is unloaded.
The memory is allocated at the start of the program, in regular memory, instead of the stack . The advantage of this is that it makes your variable or procedure totally constant, and you can't accidentally change the value. The disadvantage of this is that the memory is not deallocated until the program is terminated.