Saturday, January 21, 2012

How to Set Path for Java Unix Linux and Windows

Before We Run Any Program In Java ,We Need To Set Java Path. Java Path Is One Of The Fundamental Concept Everyone Should know Before Start Playing with Programming.


What is Path? 
PATH: is a system variable used to tel to OS all locations of exec files.
For Example:-If Installation of JAVA JDk Is done Correctly then all your java,javac,Applet Viewer,Jar etc Will be located in C:\java\bin .The Commands Are Useful To run Programs.
But these commands can be used by only that location, in case if you want To Run the program in different location,You'll Get An error AS Your CMD prompt is 'nt Smart Enough To Know The Exact Location Of Commands. As a Result Your CMD Simply says Command not recognized or Not Found.


Setting Up Java Path is Very Important And Simple Task. It Can Be done in Two Ways Either by command prompt or by using windows advanced environment editor.
First Thing Before Setting Up Path Check whether the path is already set or not, on command prompt type “javac”.




If You Find Above Messages Then Path is already Set, Otherwise Follow The Tutorial.


1.Setting Up Path In Command Prompt.


This Method is Simple Way Of Setting Up Path.We Use "set" command to set value of PATH environment variable as shown in below example:
C:\Documents and Settings>set PATH=%PATH%; C:\Program Files\Java\jdk1.6.0_26\bin



C:\Documents and Settings>set PATH=%PATH%; C:\Program Files\Java\jdk1.6.0_26\bin



Here %PATH% is Current Path.


2.Setting Up Path Using Environment variables.



1.Right Click My Computer-->Properties

2.Click on Advanced System Settings

3.Click on Environment Variables

4.In System Variables,Select path and Click Edit.

5.Copy The Bin Path of Java Directory.

6.Save it.

7.We Are Done.

Follow The Video .



How to set Java PATH in UNIX or Linux


To Set Path In UNIX Or Linux  just open any shell(terminal)  and execute below command



set PATH=${PATH}:/home/opt/jdk1.6.0_26/bin





Enhanced by Zemanta

Saturday, January 14, 2012

Character Count!






Note: Space Counts !! 

Thursday, January 12, 2012

Javascript For Redirection

In Previous Post We' Have Posted a Technique For Redirecting using "Meta Tags" .In This Post We Would Like To Present An Another Way of Redirecting Using "java Script". 


Redirection Using JavaScripts is Pretty Simple And Effective. This Method of Redirection Is Also more Search Engine Friendly. 


Follow these Steps To Redirect to a New Blog Address.



1. Login to Your dashboard--> layout- -> Edit HTML.


2.Scroll Down or find <head> Tag.


3.Paste The Following Code With Your New Blog Address.

<script type='text/javascript'>
strLoc=window.location.href;
var newLoc = strLoc.replace("Old Blogger Domain","New Blog");
window.location.replace(newLoc);
</script>



For Ex: I Want To Redirect My Traffic From My Older Blog "www.atozlyrics.blogspot.com" To New Blog Address "www.fuckyeahlyrics.blogspot.com"


Code For This As Follows:


<script type='text/javascript'>
strLoc=window.location.href;
var newLoc = strLoc.replace("atozlyrics","fuckyeahlyrics");
window.location.replace(newLoc);
</script>


Word Count.








Here is A Tool To Count Number of Words In A Text. For Source See Here.

Counting Number of Words !!

Source Code For Counting Number of Words in A Text using Javascript.



<div dir="ltr" style="text-align: left;" trbidi="on">
<form method="POST" name="Pru">
<script language="JavaScript">
function countit()
{
var formcontent=document.Pru.Prucount2.value
var trimmed =formcontent.replace(/^\s+|\s+$/g, '') ;
var str = trimmed.replace(/ +(?= )/g,'');
trimmed=str.split(" ")
document.Pru.Prucount3.value=trimmed.length
}
</script><br />



<table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr>       <td width="100%"><textarea cols="60" name="Prucount2" rows="12" wrap="virtual"></textarea></td>     </tr>
<tr>     
 <td width="100%"><div align="right">
<input onclick="countit()" type="button" value="Calculate Words" />
 <input name="Prucount3" size="20" type="text" /><br />
<div align="center">
<br />
<br />


Monday, January 9, 2012

How To Redirect Blogger URL To Another URL

Redirection Helps you Allot in Improving Your Traffic From Your Previous blog to New Blog Address.There Could Be Number of reasons you may Want the Visitors automatically Redirect To Your new Address.For ex You Have A Blog Which Give You a Decent Amount of unique Visits Daily,You Planned To move Your Blog to a New Address Either a New Sub Domain or A Hosted Domain, Redirection Helps to ensure The Traffic get To Your New Place.


There Are So Many Ways of Redirecting A Blog, we Can Do This by using java scripts or Meta tag or Php Code.
This Post Explains You Simple Way To Redirect By "Meta tags".


Steps To Be Followed.
1. Login to Your dashboard--> layout- -> Edit HTML.


2.Scroll Down or find <head> Tag.

<head>

3.Copy And Paste The Following Code Directly Below / Under <head>

<meta content='5;url=http://www.example.com/' http-equiv='refresh'/>
Note:


1. Replace http://www.example.com/ In Blue With The URL You Want To Forward To.


2. The Number 5 denotes the Time after which user is directed to new Url.


Step 4. Save your template.



Recover or Rescue Grub from live Ubuntu CD

In Last Post We Have Discussed About Restoring Windows From Grub.This Post Explains A Method Of Restoring Linux Installations Like Ubuntu Using Linux Live Desktop Cd Or a Server Cd.

Steps To Be Followed.

1.Boot From The Ubuntu Or Any Linux Variant Live Cd.
2.Open Terminal .

Applications> Accessories> Terminal.
3. In Terminal type sudo fdisk -l   . 
    It will display all the Available partition on the disk.


Identify the partition which have Linux under System column is your drive in which ubuntu linux is installed. 


4. Mount the ubuntu partition drive
       sudo mount /dev/sdXX /mnt  (example 'sudo mount /dev/sda11 /mnt' ,Here XX Stands For Your Drive.)


5.Only if you have a separate boot partition: 
            sudo mount /dev/sdYY /mnt/boot.


 6.  Mount the virtual file systems: 
            
            sudo mount --bind /dev /mnt/dev
        sudo mount --bind /proc /mnt/proc 
        sudo mount --bind /sys /mnt/sys


7. To ensure that only the grub utilities from the LiveCD get executed, mount /usr     
     sudo mount --bind /usr/ /mnt/usr 
     sudo chroot /mnt  


8. If there is no /boot/grub/grub.cfg or it's not correct, create one using 
            update-grub 
      or  update-grub2


9.Now reinstall Grub  
         grub-install /dev/sda     


 10. Verify the install 
        sudo grub-install --recheck /dev/sdX


11. Exit chroot : CTRL-D on keyboard.


12. Unmount virtual filesystems:  
           sudo umount /mnt/dev 
           sudo umount /mnt/proc
           sudo umount /mnt/sys 


If you mounted a separate /boot partition:  
           sudo umount /mnt/boot 


13. Unmount the LiveCD's /usr directory: 
          sudo umount /mnt/usr


14. Unmount last device: 
           sudo umount /mnt
15. Reboot. 
         sudo reboot.


NOTE: If you are getting /usr/sbin/grub-probe: error: cannot stat 'aufs'  error then the possible reason is that you didn't follow the commands listed above. Specifically you did not do chroot.


Credits:Sidh.

Sunday, January 8, 2012

Remove Grub & Restore Windows.

Recently I Came With a Serious Problem Which Freaked Me Out.Though I'm Not New To Linux I did a Blunder. I Hope So many New Users With Linux Would Have Been Into The Same Rabbit Hole Like Me. I Have Done Dual Booting With Ubuntu Latest Version 11.10 Over Windows With Wubi(Windows Based Ubuntu Installer,It Will Make Your Work Easy in Installing Ubuntu On Windows Machine.) .
Out of Curiosity I Deleted The Linux( Ubuntu ) Partition By Logging into Windows With Disk Manager. Then i was Gifted with a GRUB Rescue Command Prompt.  


When i Rebooted I was Welcomed With a Grub Prompt Instead of Menu to select Operating System. I Kinda Freaked Out. I Tried Some Random Commands But It Didn't Worked . then i Took The Help Of Mr. Google was  able to get into my Windows . 


I Have decided To Make a Post To Help Out The "New Users" Who Have no idea of what They are Playing With.Here Are The Steps To Restore Your Previous "windows Boot Manager".


Things You Need :
1.Windows Boot CD OR DVD (or The System Repair CD).


Steps:
1.Boot With Your Cd.
2.Select the Recovery option.
3.Navigate up to The Command Prompt.
4.Then type Following Commands.



Type            :    Diskpart          And Press Enter.
then Type  :    Select disk 0         And press Enter.( Here Select Disk Zero).
Then Type :   List Volume          


A List of Existing Drives Would Be Resulted. Identify the Drive Letter of Cd/Dvd.


Microsoft Windows [Version 6.1.7100]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
X:\Windows\system32> diskpart
Microsoft DiskPart version 6.1.7100
Copyright (C) 1999-2008 Microsoft Corporation.
On computer: VIRTUAL-7
DISKPART> select disk 0 
Disk 0 is now the selected disk.

DISKPART> list volume 
  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     P                               CD-ROM          0 B  No Media
  Volume 1     R     Drive 1   NTFS   Partition    100 MB  Healthy
  Volume 2     U     Drive 2   NTFS   Partition     11 GB  Healthy    System
  Volume 3     R     Da           NTFS  Partition     20 GB  Healthy    Boot

Type:  Exit.

5. Using The Drive Letter You Identified .Go to that Drive ( For Example In Above Drive P Is The System Repair Drive) 
Type P:

Ex:X> P:

6.Type: cd \boot And Press enter

Type: bootsect /nt60 SYS /mbr   And press enter.

This Command should find the "Active" partition with the System files and boot code and restore your Windows Boot Manager.

7. Restart And Get Back Your Good Old Windows . 

GRUB - COMMAND LIST

What is Grub?


Grub is a Bootloader( first software program that runs when a computer starts. It is responsible for loading and transferring control to the operating system) Package For GNU Project.


It Stands For Grand Unified Bootloader.Grub is developed to support multiple operating systems and allow the user to select among them during boot-up.Grub is Mostly Used in Unix Like Operating Systems.Most Of The Linux Distributions Available in The Industry Uses Grub as its Default Bootloader.


So,When You Do MultiBoot,I.e Dual Booting With a Linux Os On Windows, Grub Replaces Your Default Windows Bootmanager Allowing You To Flexibily Choose Between Windows And Other OS.


Here Are The GRUB Commands.


Command                         Description
blocklistblocklist FILE
Print the blocklist notation of the file FILE.
bootBoot the OS/chain-loader which has been loaded.
catcat FILE
Print the contents of the file FILE.
chainloaderchainloader [--force] FILE
Load the chain-loader FILE. If --force is specified, then load it forcibly, whether the boot loader signature is present or not.
colorcolor NORMAL [HIGHLIGHT]
Change the menu colors. The color NORMAL is used for most lines in the menu, and the color HIGHLIGHT is used to highlight the line where the cursor points. If you omit HIGHLIGHT, then the inverted color of NORMAL is used for the highlighted line. The format of a color is "FG/BG". FG and BG are symbolic color names. symbolic color name must be one of these: black, blue, green, cyan, red, magenta, brown, light-gray, dark-gray, light-blue, light-green, light-cyan, light-red, light-magenta, yellow and white. But only the first eight names can be used for BG. You can prefix "blink-" to FG if you want a blinking foreground color.
configfileconfigfile FILE
Load FILE as the configuration file.
debugTurn on/off the debug mode.
devicedevice DRIVE DEVICE
Specify DEVICE as the actual drive for a BIOS drive DRIVE. This command can be used only in the grub shell.
displaymemDisplay what GRUB thinks the system address space map of the machine is, including all regions of physical RAM installed.
embedembed STAGE1_5 DEVICE
Embed the Stage 1.5 STAGE1_5 in the sectors after MBR if DEVICE is a drive, or in the "bootloader" area if DEVICE is a FFS partition. Print the number of sectors which STAGE1_5 occupies if successful.
findfind FILENAME
Search for the filename FILENAME in all of partitions and print the list of the devices which contain the file.
fstestToggle filesystem test mode.
geometrygeometry DRIVE [CYLINDER HEAD SECTOR [TOTAL_SECTOR]]
Print the information for a drive DRIVE. In the grub shell, you canset the geometry of the drive arbitrarily. The number of the cylinders, the one of the heads, the one of the sectors and the
one of the total sectors are set to CYLINDER, HEAD, SECTOR and TOTAL_SECTOR, respectively. If you omit TOTAL_SECTOR, then it will be calculated based on the C/H/S values automatically.
helphelp [PATTERN ...]
Display helpful information about builtin commands.
hidehide PARTITION
Hide PARTITION by setting the "hidden" bit in its partition type code.
impsprobeProbe the Intel Multiprocessor Specification 1.1 or 1.4 configuration table and boot the various CPUs which are found into a tight loop.
initrdinitrd FILE [ARG ...]
Load an initial ramdisk FILE for a Linux format boot image and set the appropriate parameters in the Linux setup area in memory.
installinstall STAGE1 [d] DEVICE STAGE2 [ADDR] [p] [CONFIG_FILE] REAL_CONFIG_FILE]
Install STAGE1 on DEVICE, and install a blocklist for loading STAGE2 as a Stage 2. If the option `d' is present, the Stage 1 will always look for the disk where STAGE2 was installed, rather
than using the booting drive. The Stage 2 will be loaded at address ADDR, which will be determined automatically if you don't specify it. If the option `p' or CONFIG_FILE is present, then the first block of Stage 2 is patched with new values of the partition and name of the configuration file used by the true Stage 2 (for a Stage 1.5, this is the name of the true Stage 2) at boot time. If STAGE2 is a Stage 1.5 and REAL_CONFIG_FILE is present, then the Stage 2 CONFIG_FILE is patched with the configuration filename REAL_CONFIG_FILE.
ioprobeioprobe DRIVE
Probe I/O ports used for the drive DRIVE.
kernelkernel FILE [ARG ...]
Attempt to load the primary boot image from FILE. The rest of the line is passed verbatim as the "kernel command line". Any modules must be reloaded after using this command.
makeactiveSet the active partition on the root disk to GRUB's root device. This command is limited to _primary_ PC partitions on a hard disk.
mapmap TO_DRIVE FROM_DRIVE
Map the drive FROM_DRIVE to the drive TO_DRIVE. This is necessary when you chain-load some operating systems, such as DOS, if such an OS resides at a non-first drive.
modulemodule FILE [ARG ...]
Load a boot module FILE for a Multiboot format boot image (no interpretation of the file contents is made, so users of this command must know what the kernel in question expects). The rest
of the line is passed as the "module command line", like the `kernel' command.
modulenounzipmodulenounzip FILE [ARG ...]
The same as `module', except that automatic decompression is disabled.
pausepause [MESSAGE ...]
Print MESSAGE, then wait until a key is pressed.
quitExit from the GRUB shell.
readread ADDR
Read a 32-bit value from memory at address ADDR and display it in hex format.
rootroot [DEVICE [HDBIAS]]
Set the current "root device" to the device DEVICE, then attempt to mount it to get the partition size (for passing the partition descriptor in `ES:ESI', used by some chain-loaded bootloaders),
the BSD drive-type (for booting BSD kernels using their native boot format), and correctly determine the PC partition where a BSD sub-partition is located. The optional HDBIAS parameter is a number to tell a BSD kernel how many BIOS drive numbers are on controllers before the current one. For example, if there is an IDE disk and a SCSI disk, and your FreeBSD root partition is on the SCSI disk, then use a `1' for HDBIAS.
rootnoverifyrootnoverify [DEVICE [HDBIAS]]
Similar to `root', but don't attempt to mount the partition. This is useful for when an OS is outside of the area of the disk that GRUB can read, but setting the correct root device is still desired. Note that the items mentioned in `root' which derived from attempting the mount will NOT work correctly
setkeysetkey TO_KEY FROM_KEY
Change the keyboard map. The key FROM_KEY is mapped to the key TO_KEY. A key must be an alphabet, a digit, or one of these: escape, exclam, at, numbersign, dollar, percent, caret,
ampersand, asterisk, parenleft, parenright, minus, underscore, equal, plus, backspace, tab, bracketleft, braceleft, bracketright, braceright, enter, control, semicolon, colon, quote, doublequote, backquote, tilde, shift, backslash, bar, comma, less, period, greater, slash, question, alt, space, capslock, FX (X is a digit), and delete.
setupsetup INSTALL_DEVICE [IMAGE_DEVICE]
Set up the installation of GRUB automatically. This command uses the more flexible command "install" in the backend and installs GRUB into the device INSTALL_DEVICE. If IMAGE_DEVICE is specified, then find the GRUB images in the device IMAGE_DEVICE,
otherwise use the current "root device", which can be set by the command "root".
splashscreensplashscreen FILE
Load file as splashscreen hook and call it each time the screen is to be cleared
testloadtestload FILE
Read the entire contents of FILE in several different ways and compares them, to test the filesystem code. The output is somewhat cryptic, but if no errors are reported and the final `i=X, filepos=Y' reading has X and Y equal, then it is definitely consistent, and very likely works correctly subject to a consistent offset error. If this test succeeds, then a good next step is to try loading a kernel.
unhideunhide PARTITION
Unhide PARTITION by clearing the "hidden" bit in its partition type code.
uppermemuppermem KBYTES
Force GRUB to assume that only KBYTES kilobytes of upper memory are installed. Any system address range maps are discarded.