Saturday, March 26, 2011

Open or Extracting rar Files under Fedora Linux

Q. How do I open rar archive files under Linux / UNIX operating systems?

A. RAR files are in compressed archive format, if you have downloaded rar files from the Internet, you need to unpack or unrar them (extract rar files).
RAR is a proprietary file format for data compression and archiving, developed by Eugene Roshal. Under Linux and UNIX, use command called unrar. By default unrar is not being installed on Linux, FreeBSD or UNIX oses. You can install unrar command with the help of apt-get or yum command.

Download the binary package from official rarlab site

$ cd /tmp
$ wget http://www.rarlab.com/rar/rarlinux-3.6.0.tar.gz

untar the file

$ tar -zxvf rarlinux-3.6.0.tar.gz

Both unrar and rar commands are located in rar sub-directory. Just go to rar directory:

$ cd rar
$ ./unrar

Now copy rar and unrar to /bin directory:

# cp rar unrar /bin

How to use unrar

unrar command supports various options below are common options that you need to use everyday.
Task: To open rar (unpack) file in current directory type command:

$ unrar e file.rar

Please note that replace file.rar filename with your actual filename.
Task: List (l) file inside rar archive:

$ unrar l file.rar

Task: To extract (x) files with full path type command:

$ unrar x file.rar

(D) To test (t) integrity of archive, file type command:

$ unrar t file.rar

Saturday, March 12, 2011

Overridden Methods


class Animal {
public void eat() {
System.out.println("Generic Animal Eating Generically");
}
}


class Horse extends Animal {
public void eat() {
System.out.println("Horse eating hay, oats and horse treats");
}
public void buck() { }
}

public class TestAnimals {
public static void main (String [] args) {
Animal a = new Animal();
Animal b = new Horse(); //Animal ref, but a Horse object
a.eat(); // Runs the Animal version of eat()
b.eat(); // Runs the Horse version of eat()
b.buck(); // Can't invoke buck(); Animal class doesn't have that method
}
}


Reason: The compiler looks only at the reference type, not the instance type.