03 February 2014

Getting Gradle integrated into Eclipse

It was nice learning Gradle, but I felt it'd be a bit more convenient to have Gradle inside the Eclipse IDE. Gradle is already present in the Netbeans IDE, but for Eclipse you have to install it like so:

This project at Github is what you need: https://github.com/spring-projects/eclipse-integration-gradle

From the documentation on the website, just follow the same steps:
  • Open the Eclipse IDE
  • Select Help > Install new software
  • Paste a Gradle update site link (http://dist.springsource.com/release/TOOLS/gradle) into the "Work with" text box. 
  • Ensure that the option "Group Items by Category" is enabled.
  • Select the top-level node 'Extensions / Gradle Integration'.
  • Click "Next".
  • Review the list of software that will be installed. Click "Next" again.
  • Review and accept licence agreements and Click "Finish".
It'll take a while to install:


Now in Project Explorer, right click on your project, go to Run As > 2. Gradle... to run the project under whichever tasks you want to select.


You don't always have to return to this dialog box. The next time, you can simply run the selected tasks using Run As > 1. Gradle.
If you add any tasks externally, click the refresh button to view that task.

It's that simple. Happy building! :)

01 February 2014

How to add the path of the JDK to JAVA_HOME in Linux?


If you've already installed the JDK, it's as simple as this:
type locate jdk and search for the path.

Mine was in /usr/local/jdk1.7.0_45/

So I opened up bash_profile with
vim ~/.bash_profile

and added the following line into it.
JAVA_HOME=/usr/local/jdk1.7.0_45
export JAVA_HOME


Also add :
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/gradle-1.10/bin:/usr/local/jdk1.7.0_45/bin
 

So that when you execute commands like jar -xf somejar.jar, the executables will be recognized.


Then type source ~/.bash_profile to activate the changes you made (basically the whole of bash_profile will be executed again).

That's it! all programs will recognize JAVA_HOME. I had to do this for Gradle to recognize the path. Without the path, it didn't compile Java programs.

26 January 2014

Gradle installation and example / tutorial for Linux (Fedora 20)

When I wanted to re-learn Ant, I found Maven. When I found Maven, I found out about Gradle being better than Maven. And indeed it did seem to be so.
The Gradle build script appeared a lot shorter and more powerful than Maven. There is also a more feature-rich C++ version for Gradle coming up and a demo and cpp plugin already available.

This is intended to be a simple tutorial for Gradle. Recording my path in learning the what and why of Gradle.

To give it a shot, download the Gradle binaries, extract them into /usr/local/ with sudo unzip gradle-1.10-bin.zip.

To run Gradle, you have to add the path of the Gradle bin folder to PATH. So do this:

sudo vim ~/.bash_profile

Add the path this way in .bash_profile

 PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/gradle-1.10/bin

Save, exit and type source ~/.bash_profile to incorporate the changes immediately.

Type gradle -v and you'll see the Gradle version, build time, build number etc. Congratulations.

To try out Gradle, create a file named build.gradle file in any directory you like and as the Gradle documentation says, paste the following content in it:

task hello {
    doLast {
        println 'Hello world!'
    }
}

Save, exit and then type gradle hello for the script to execute (gradle.build isn't exactly a build script. It's a build configuration script; which means that it's a script we write, which internally creates the necessary build script automatically. Saves us a lot of trouble, really!)

Now that you know Gradle works, you have to understand that Gradle thinks in terms of high-level tasks. You have to learn the syntax of writing tasks.

Type gradle tasks at the terminal (in some other directory which does not have a build.gradle file in it) to see the list of tasks that gradle supports by default. You'll see something like this:

All tasks runnable from root project
------------------------------------------------------------

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Help tasks
----------
dependencies - Displays all dependencies declared in root project 'nav'.
dependencyInsight - Displays the insight into a specific dependency in root project 'nav'.
help - Displays a help message
projects - Displays the sub-projects of root project 'nav'.
properties - Displays the properties of root project 'nav'.
tasks - Displays the tasks runnable from root project 'nav'.

To see all tasks and more detail, run with --all.

BUILD SUCCESSFUL

Total time: 3.327 secs
This means that similar to how you had defined a "hello" task above, Gradle already has such tasks named dependencies, help, properties etc., already defined somewhere. To see proof of it, type gradle help and see the result. These tasks are already part of Gradle by default. That's why you didn't need a build.gradle file.

Now go back to the directory where you created the build.gradle file. Now type gradle tasks and you'll see a similar output as above, with the additional display of "hello" as a task. Which means that in this directory if you type gradle hello, the hello task will be executed.

Gradle encourages convention over configuration, so it'll be easier for us to create a new project with the following directory structure:

src/main/java  for production Java source
src/main/resources for production resources
src/test/java for test Java source
src/test/resources for test resources
src/sourceSet/java for java source for the given source set
src/sourceSet/resources for resources for the given source set

Create a simple java class inside src/main/java, named Main.java with the following contents.
public class Main
{
    public static void main(String[] args)
    {
        System.out.println("in main");
    }//main
 }//Main class

Go back to the folder where your build.gradle file is. Now to be able to build a Java project, you haven't created any tasks. Thankfully, Gradle comes with a plugin which has the necessary tasks for building a Java project, predefined. Open your build.gradle file and add this line as the fist line of the file: 

apply plugin: 'java'


Save and exit and type gradle tasks. Now you'll see a lot more tasks listed. Running the gradle build command will automatically find your Main.java file, create a build directory for it, place the ".class" file there and will also create a jar file for you in build/libs.

Now if you try to run the jar file with java -jar jarname.jar, it won't execute because you didn't specify the application entry point in manifest.mf.

So now open your build.gradle file and add the following info to it:


apply plugin: 'java'

jar {
    manifest {
        attributes(
            "Implementation-Title": "Tutorial",
            "Implementation-Version": 1.0,
            "Main-Class": "Main"
            )
    }
}
Now executing the gradle build command will create the manifest file and you'll be able to execute the jar. Similar to make files in C and C++, you can run a clean command with gradle clean and the build directory will get cleared.


Gradle can  automatically create Eclipse project files for you. Just add to your build.gradle, the following line 
apply plugin: 'eclipse'
Type gradle tasks and see a new set of tasks you've got.

Now type gradle eclipse and when you type ls -altr you'll see the Eclipse project files have been generated. Open Eclipse, go to File > Import > General > Existing projects into workspace and you'll be able to use this newly created Eclipse project.













Learn to use a mouse with your other hand

If you're working a lot on the computer, wrist discomfort is a sign that you should be taking rest more often. If you still have to work, and you're sure the discomfort is because of using the mouse, then do consider this:

Learn to use the mouse with your other hand. Switching hands this way gives your overworked wrist the rest it needs. I started doing it and it really helped. It'll take a couple of weeks of practice to get used to it, but it'll help a lot. Do give it a shot!

Installing Jenkins on Fedora 20

Typing sudo yum install jenkins strangely didn't work (even though it was on the Jenkins website). It's then I realized that what they showed on the website was a three step process and not options to choose from. The first two steps are meant to do the initial setup necessary for downloading jenkins. So this is what you do:

Type:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins

Once that's done, use the following for their obvious functions:
sudo service jenkins start
sudo service jenkins stop
sudo service jenkins restart 

So  start Jenkins, open a browser and type "localhost:8080" in the address bar. You'll see the Jenkins page. The default port used by Jenkins is 8080. 

_______________________________________


Bonus info

You can create aliases for Jenkins in bashrc so you won't have to type those long commands again.
Open up bashrc with 

vi ~/.bashrc

and type in these lines into it.

alias startjen='sudo service jenkins start'
alias stopjen='sudo service jenkins stop'
alias rejen='sudo service jenkins restart'

Save and exit by pressing. (Make sure you type capital Z's).

Escape key and ZZ

Type this at the command prompt to activate the aliases you just created

source ~/.bashrc

The feel of Linux UI vs Windows UI vs Mac UI vs the ideal UI

I've worked on all three OS'es, and it's just a personal opinion that the UI I've loved the most is that of Windows XP.

People who haven't had the chance to venture into the field of interaction design would usually not mind this aspect, but after having had internationally acclaimed interaction designers as my bosses for two years, I've developed a similar gut -feel for quality that they have.

A product has to look and feel right. It has to have an emotional value that appeals to a certain kind of user.

The Windows XP UI has a nimble, crisp, efficient feel to it. Especially after you disable the special animations and effects in the performance settings. The 'click' sound played on every folder click adds to the experience. It just feels right. Feels comfortable to work on (except maybe for the way the taskbar tab flashes in orange :-) ). The UI responds promptly to clicks and key-presses. A good operating system for a new person entering the world of computers.

The Linux UI has a lot of visible effort put into creating it. With distros like Fedora and Ubuntu opting for a minimalist design, the UI has become less usable for a person already accustomed to an OS like Windows. Much less usable for a person with no experience with computers. The UI feels cumbersome to use. It's not as responsive to clicks as Windows XP, and some operations are just un-intuitive. Eg: If a Firefox window is open and you click the Firefox icon again, it doesn't open another window. Right clicking on the file-browser does not produce the option for creating a new text file. Clicking the shutdown button shows options to shutdown, but no logout button (you have to click the user icon to see the logout button). 
But then again, Linux was not really meant to have a lovely UI (although I wish they'd make it like Windows XP). It's power comes from the commandline, and that's what programmers love about it! In terms of the commandline and security, Linux beats Windows hands-down any day. As a programmer, this is the reason I like Linux.

The Mac UI, although pretty much like Linux, has a kind of a sticky, dragging feel to it (as compared to the crisp feel of XP). I was using a G4. It's a combined effect of the hardware and the software that produces this feel. In terms of intuitiveness, the Mac was good. I just loved the fact that to remove a program, I could just delete the folder instead of being like the add and remove programs of Windows or the uninstall techniques of Linux. The animations and sounds were un-intrusive and pleasant. 

The Ideal UI though, as just a figment of my imagination, would be part of a machine that can read the mind of a living being (note that I didn't mention it as 'human'). It would be a machine we wouldn't have to talk to, for it to understand exactly what task we want to accomplish. It would not be made of metal or plastic or any material which would incorporate delays in input/response. It would give us the perfect aesthetic and emotional feel customized to our personality and interface needs. Such a technology may be very far away in the future, but I'm predicting it now because I do believe it can be a reality.

Until then, back I go to working on my hobby project for which I'm trying to design an intuitive UI.

18 January 2014

Installing Adobe Flash on Fedora 20

Numerous people including me have been at a loss when we tried installing Adobe Flash on or Fedora installations and it never worked!
Finally, I found that there is a solution that works:
 
sudo yum install flash-plugin nspluginwrapper alsa-plugins-pulseaudio libcurl
 
Enjoy! :)

Installing Net-SNMP and SNMPTT in Fedora 20

Documenting this on-the-fly for my reference and anyone else who would find it useful.

After freshly installing Fedora 20, I was perplexed to find that it didn't have gcc or g++ installed. So step 1 is to get them. (You don't really have to use sudo in all steps below)

sudo yum install gcc 

sudo yum install gcc-c++

You can also optionally install mysql (if you wish to have MYSQL Trap Logging) like so:

sudo yum install mysql
sudo yum install mysql-server
sudo yum install mysql-devel
sudo chgrp -R mysql /var/lib/mysql
sudo chmod -R 770 /var/lib/mysql
sudo service mysqld start 


Also ensure Perl and a supporting module is installed:

sudo yum install perl

(you might be able to install all supporting modules for Perl like this: "sudo yum install perl-*", do give it a shot. It'll be a larger download though)

You'll need two ExtUtils of Perl which you can either install separately like this:

sudo yum install perl-ExtUtils-MakeMaker
sudo yum install perl-ExtUtils-Embed

or install everything in one go like so:

sudo yum install perl-ExtUtils-*

For running snmptt, you'll also need:

sudo yum install perl-Config-*
 
 

Then download Net-SNMP, and extract it into your /usr/local/ folder with:

sudo tar -xvzf net-snmp-5.7.2.tar.gz.

Navigate into the newly created net-snmp directory and type:


sudo ./configure --enable-embedded-perl --enable-shared --with-mysql

Or if you don't want embedded perl, type (you'll need to install with embedded perl for this tutorial):

sudo ./configure --with-perl-modules --with-mysql

You'll be given a lot of options. Just keep pressing enter for all of them (unless you want to configure it differently).
Once configuration is done, type:

sudo make -j 4

The -j 4 is to tell make that it can use the four cores of my processor. It works faster this way, by dividing the make process into separate jobs which complete parallelly. You can also simply type "sudo make". At any point if you want to redo the make process, type "sudo make clean" and you'll be able to start from the configure step again.


Now you can optionally start "make test" which is not really required, but it is what helped me find out that I didn't have ExtUtils-MakeMaker installed. I wasn't able to make install without it, and the net-snmp mailing list was unable to figure it out either. I updated the mailing list with the solution when I found it.

sudo make test
sudo make install 

...and tadaah! You now have net-snmp installed!
The snmptrapd file which snmptt requires, you'll now find installed in /usr/local/sbin/snmptrapd

To be able to start and stop snmptrapd, a script is also included.
sudo cp /usr/local/net-snmp-5.7.2/dist/snmptrapd-init.d /etc/rc.d/init.d/snmptrapd

You can optionally use the above script to start snmptrapd with the command "sudo service snmptrapd start"or "snmptrapd -On"



------------------------------------

Now for snmptt:

Extract the snmptt tar file into /usr/local/ using:

sudo tar -xvzf snmptt_1.4.tgz

Navigate into the newly created snmptt_1.4 directory and create a file named snmptrapd.conf:

sudo vim snmptrapd.conf



To test out snmptrapd, add the line "disableAuthorization yes" to the snmptrapd.conf file (remove this line later for proper authorizations) and type the following command at the terminal:

sudo /usr/local/sbin/snmptrapd -f -Lo -c /usr/local/snmptt_1.4/snmptrapd.conf

snmptrapd will start and will keep listening for traps.
Meanwhile, download and start a MIB browser like the one iReasoning has.
Go to Tools > Trap sender in the MIB browser and type the address to send traps to, as "localhost" (without the quotes). Then click the "Send Trap" and immediately, you'll see the trap being received at the terminal where you started snmptrapd.


You have the choice of installing snmptt as a standard handler or as an embedded handler. I'd recommend installing as the embedded handler, because it is loaded when snmptrapd is started, so it won't need a process to be created everytime a trap is received (which is what happens with the standard handler). Type the following commands:

sudo cp snmptt /usr/sbin 
sudo chmod +x /usr/sbin/snmptt
sudo cp snmptthandler-embedded /usr/sbin/
sudo mkdir /etc/snmp/
sudo cp snmptt.ini /etc/snmp/ (you can change settings in this file)

sudo cp examples/snmptt.conf.generic /etc/snmp/snmptt.conf
sudo mkdir /var/log/snmptt/

Open the snmptrapd.conf file and add the following line to it "perl do "/usr/sbin/snmptthandler-embedded";"

sudo mkdir /var/spool/snmptt

sudo cp snmptt-init.d /etc/rc.d/init.d/snmptt (this is a script that can be used to start and stop snmptt)

and now add snmptt as a service:
sudo chkconfig --add snmptt

Configure snmptt to start at runlevel 2345
sudo chkconfig --level 2345 snmptt on

The above command will start snmptt automatically on reboot. You can also start it right now using:

sudo service snmptt start

To stop it, use:
 
sudo service snmptt stop


Copy a script to rotate log files:
sudo cp snmptt.logrotate /etc/logrotate.d/snmptt (you can edit this file if you wish)



20 October 2013

Prevent eye strain with a software that reminds you to blink and exercise

UPDATE 2018: The "look up and down, look outside the window" etc. are exercises that do not work. See this: http://nrecursions.blogspot.com/2018/03/eye-strain-is-not-caused-by-digital.html
UPDATE 2020: The real cure for eye strain: https://nrecursions.blogspot.com/2020/11/the-real-cure-for-eye-strain.html


----------------------------------


It is only when I was affected with severe eye strain that I realized how important it is to get enough of sleep everyday and to take breaks while working on the computer.

Even if you're not having back pain or eye strain, I'd still recommend that you install a software like Eye Leo or Work Rave (works on Linux too) to remind you to take breaks. I found Eye Leo to be nice, but there are more alternatives.
It has short-breaks like in the image above, and long breaks where the entire screen is dimmed. You can change the settings (mine are short breaks every 3 minutes and long breaks every 30 minutes for 5 minutes at a time). The application sits quietly in the system tray and starts when the system starts.

Some corrections: When your eye muscles are tired, it's wrong to do eye exercises. The people who came up with the eye exercise routine had the logic that when you look leftward, the extraocular muscles of the right eye would relax and allow the lactic acid to flow away. I know from experience that it's just a piece of theory that doesn't work in practice. Simply keep your eyes closed, relax your face muscles and neck muscles. That's all you need to relax your eyes during daytime. At night, make sure you get uninterrupted 8 hours of sleep. And simply blinking and drinking enough water is enough to ensure sufficient lubrication of your eyes via tears. After almost a decade of strain I realized that doctors are actually clueless about how to cure eye strain. The incompetent lot give people spectacles and eye drops instead of advising sleep and rest. 
For more information on curing eye strain that actually works, see this: https://nrecursions.blogspot.com/2018/03/eye-strain-is-not-caused-by-digital.html

I would recommend this software even to people who don't wear spectacles and even to people who say they have no strain while working on the computer. You need to take rest.

04 August 2013

An equivalent for MS Paint in Linux

Well honestly, there's no equivalent that I found good enough in Linux. MS Paint has an ease of use and functionality that's just about good enough for drawing and image editing, but not as complex as something like Gimp or Photoshop. I like using MS Paint for simple editing tasks.

There is one program which comes close to MS Paint. It's called mtpaint.
Install it with :
sudo yum install mtpaint
It's able to perform the necessary basic image editing tasks and drawing tasks required.




Linux also has CinePaint (comes with even a smudge tool, import capability for xcf, splines, but can't import even a png file and crashed when I did a colour sampling), xpaint (with a UI that's rather primitive and it crashed when I tried to select-all and move the graphics).

For children, there's a nice application called Tuxpaint. You can install it with sudo yum install tuxpaint. It's got simple features and accompanying sounds which will make it a joy for little kids to use.


Some others exist too for Ubuntu.

Say thank you or donate

02 September 2010

Setting up your bash prompt for colours, aliases and other things

One of the little joys in life is to have a nice coloured bash prompt and a lot of aliases to simplify navigation in bash.

I've placed most of my commands in ~/.bash_aliases.


To know how to colour a terminal, see this and this
Being able to create aliases to commands is one of the best things I've found out about the bash shell. You'll find a similar functionality in MS-DOS, called doskey.

These are the aliases I use in bashrc. Typing "cd .." became so annoying that the alias "f" (for "fall" to the below directory) became a handy tool.

# User specific aliases and functions
alias bashrc='gedit ~/.bashrc;source ~/.bashrc;echo bashrc has been sourced'
alias bashaliases='gedit ~/.bash_aliases;source ~/.bash_aliases;echo bash_aliases has been sourced'    
alias bashprofile='gedit ~/.bash_profile;source ~/.bash_profile;echo bash_profile has been sourced'
alias aliases="clear;cat ~/.bash_aliases|grep --color \"alias\""
alias home='cd;ls;pwd'
alias root='cd /;ls;pwd'
alias die='halt -p'
alias desktop='cd ~/Desktop;ls;pwd'
alias f='cd ..;ls;pwd'
alias ff='cd ../..;ls;pwd'
alias fff='cd ../../..;ls;pwd'
alias ffff='cd ../../../..;ls;pwd'
alias fffff='cd ../../../../..;ls;pwd'
alias ffffff='cd ../../../../../..;ls;pwd'
alias fffffff='cd ../../../../../../..;ls;pwd'
alias ffffffff='cd ../../../../../../../..;ls;pwd'
alias home='cd;ls;pwd'
alias root='cd /;ls;pwd'
alias shtdn='halt -p'
#alias startsql="service mysqld start"
#adding a hibernate option which I found while using Fedora20
alias hibernate='systemctl hibernate'
#--- For a coloured, customised prompt
# 0 is for non-bold colour. Replace it with 1 for bold
# 31m is the colour
# \u makes it show the username
# \h makes it show the address
# \W makes it show the directory name. Use \w for showing the full path
#export PS1="\e[0;32m[\u@\h \W]\$ \e[m"
#export PS1="\e[1;32m[\W] \e[m"
#alias br='xrandr --output eDP1 --brightness 0.5'
#alias brightness='xrandr --output eDP1 --brightness '
alias night='sct 2300'
alias day='sct 4000'
alias normal='sct'
#to shift memory from swap space to RAM
alias swap='sudo swapoff -a; sudo swapon -a'
#to convert webp files to png
alias convertwebp="find ./ -name '*.webp' -exec dwebp {} -o {}.png \;; find . -type f -name '*.webp' -delete"
#irest is a program I created
#alias restartirest='kill -9 $(pgrep -f 'irest');cd;nohup java -jar /someFolder/iRestTracker/irest/dist/irest.jar&'
alias killirest="kill -9 $(pgrep -f 'iRest')"
alias pauseirest="kill -STOP $(pgrep -f 'iRest')"
alias resumeirest="kill -CONT $(pgrep -f 'iRest')"
alias ireststatus="ps -aef | grep iRest"
alias irest="cd ~;python -B /home/nav/iRest/main.py >> iRestErrors.log"
alias ufw='sudo ufw'

alias pushall="git push --all origin"
alias pullall="git pull --all"
alias commit='git add -A && git commit -m '
 
alias deb='sudo dpkg -i '
alias showinstalled='sudo apt list --installed'
alias install='sudo apt-get install -y '
alias uninstall='sudo apt-get remove -y '
alias update='sudo apt-get update '
alias aptsearch='apt-cache search ' 
alias autoremove='sudo apt -y autoremove'
alias fixbroken='sudo apt --fix-broken install' 

alias updatedb='sudo updatedb'
 
#To play a beep in Ubuntu after running some program from the bash prompt.
alias beep='paplay /usr/share/sounds/freedesktop/stereo/complete.oga'
 
#To use wipe, first install via sudo apt-get install -y wipe
alias shred='wipe -rfiqQ 1 '

alias cleanpc='sudo bleachbit'
alias invert='xcalib -i -a'
alias sysinfo='inxi -Fxz;sudo get-edid | parse-edid;sudo lshw -c memory'
alias osinfo='lsb_release -a'
alias monitoroff='xset dpms force off'
alias lastsuspend='journalctl | grep -i suspend | tail | grep "Entering sleep state"'
alias lastshutdown='last|head'
 
alias netio='sudo nethogs'
alias gedit='xed' #for Linux Mint


Say thank you or donate

01 August 2010

Installing gcc 4.4.2 on Fedora 8

( Note from the future: This was the first of my build-from-source attempts, hence the excitement and detail.  )

I recommend that you go through the entire document first before following the steps (because some steps were performed wrong and corrected later. Other steps were repeated un-necessarily). The steps are numbered as 1., 2., 3. etc.

GCC 4.4.2 installation on Fedora 8:
How I did it:
1. Placed the gcc-4.4.2 folder in home and created a folder called gccbuild in home.
2. typed gcc -v in the terminal and got the following info

Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)


3. Entered cd gccbuild/
4. Typed ../gcc-4.4.2/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic --host=i386-redhat-linux
5. and got the following message:
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
checking build system type... i686-pc-linux-gnu
checking host system type... i386-redhat-linux-gnu
checking target system type... i386-redhat-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for i386-redhat-linux-gcc... i386-redhat-linux-gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether i386-redhat-linux-gcc accepts -g... yes
checking for i386-redhat-linux-gcc option to accept ANSI C... none needed
checking for i386-redhat-linux-g++... i386-redhat-linux-g++
checking whether we are using the GNU C++ compiler... yes
checking whether i386-redhat-linux-g++ accepts -g... yes
checking for i386-redhat-linux-gnatbind... no
checking for gnatbind... no
checking for i386-redhat-linux-gnatmake... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for correct version of gmp.h... yes
checking for correct version of mpfr.h... no
configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.2+.
Try the --with-gmp and/or --with-mpfr options to specify their locations.
Copies of these libraries' source code can be found at their respective
hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/.
See also http://gcc.gnu.org/install/prerequisites.html for additional info.
If you obtained GMP and/or MPFR from a vendor distribution package, make
sure that you have installed both the libraries and the header files.
They may be located in separate packages.

6. Tried ../gcc-4.4.2/configure --prefix=/opt/
7. and got the following messages:
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for correct version of gmp.h... yes
checking for correct version of mpfr.h... no
configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.2+.
Try the --with-gmp and/or --with-mpfr options to specify their locations.
Copies of these libraries' source code can be found at their respective
hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/.
See also http://gcc.gnu.org/install/prerequisites.html for additional info.
If you obtained GMP and/or MPFR from a vendor distribution package, make
sure that you have installed both the libraries and the header files.
They may be located in separate packages.

8. Tried ../gcc-4.4.2/configure --prefix=/usr/local --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-checking=release --disable-libunwind-exceptions
9. and got:
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for correct version of gmp.h... yes
checking for correct version of mpfr.h... no
configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.2+.
Try the --with-gmp and/or --with-mpfr options to specify their locations.
Copies of these libraries' source code can be found at their respective
hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/.
See also http://gcc.gnu.org/install/prerequisites.html for additional info.
If you obtained GMP and/or MPFR from a vendor distribution package, make
sure that you have installed both the libraries and the header files.
They may be located in separate packages.

10. Trying ../gcc-4.4.2/configure --prefix=/usr/local --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-checking=release --disable-libunwind-exceptions --with-gmp=/usr/share/doc/gmp-4.2.2
11. and got:
e-libunwind-exceptions --with-gmp=/usr/share/doc/gmp-4.2.2
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for correct version of gmp.h... yes
checking for correct version of mpfr.h... no
configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.2+.
Try the --with-gmp and/or --with-mpfr options to specify their locations.
Copies of these libraries' source code can be found at their respective
hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/.
See also http://gcc.gnu.org/install/prerequisites.html for additional info.
If you obtained GMP and/or MPFR from a vendor distribution package, make
sure that you have installed both the libraries and the header files.
They may be located in separate packages.

12. downloaded mpfr-2.4.2 from http://www.mpfr.org/
13. logged in as root and extracted the tar.bz2 to /usr/share/doc/
14. entered the mpfr-2.4.2 folder, typed 'configure' and typed 'make'
15. Tried ../gcc-4.4.2/configure --prefix=/usr/local --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-checking=release --disable-libunwind-exceptions --with-gmp=/usr/share/doc/gmp-4.2.2 --with-mpfr=/usr/share/doc/mpfr-2.4.2
16. and got:
e-libunwind-exceptions --with-gmp=/usr/share/doc/gmp-4.2.2 --with-mpfr=/usr/share/doc/mpfr-2.4.2
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for correct version of gmp.h... yes
checking for correct version of mpfr.h... no
configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.2+.
Try the --with-gmp and/or --with-mpfr options to specify their locations.
Copies of these libraries' source code can be found at their respective
hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/.
See also http://gcc.gnu.org/install/prerequisites.html for additional info.
If you obtained GMP and/or MPFR from a vendor distribution package, make
sure that you have installed both the libraries and the header files.
They may be located in separate packages.

17. From the /usr/share/doc folder I did an "mv mpfr-2.4.2 /home/username/gcc-4.4.2/mpfr"
18. Tried ../gcc-4.4.2/configure --prefix=/usr/local --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-checking=release --disable-libunwind-exceptions --with-gmp=/usr/share/doc/gmp-4.2.2
19. and got:
ibunwind-exceptions --with-gmp=/usr/share/doc/gmp-4.2.2
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for version 0.10 of PPL... no
checking for correct version of CLooG... no
The following languages will be built: c,c++,fortran,java,objc
*** This configuration is not supported in the following subdirectories:
target-libada gnattools
(Any other directories should still work fine.)
checking for bison... bison -y
checking for bison... bison
checking for gm4... no
checking for gnum4... no
checking for m4... m4
checking for flex... flex
checking for flex... flex
checking for makeinfo... makeinfo
checking for expect... no
checking for runtest... no
checking for ar... ar
checking for as... as
checking for dlltool... no
checking for ld... ld
checking for lipo... no
checking for nm... nm
checking for ranlib... ranlib
checking for strip... strip
checking for windres... no
checking for windmc... no
checking for objcopy... objcopy
checking for objdump... objdump
checking for cc... cc
checking for c++... c++
checking for gcc... gcc
checking for gcj... gcj
checking for gfortran... gfortran
checking for ar... no
checking for ar... ar
checking for as... no
checking for as... as
checking for dlltool... no
checking for dlltool... no
checking for ld... no
checking for ld... ld
checking for lipo... no
checking for lipo... no
checking for nm... no
checking for nm... nm
checking for objdump... no
checking for objdump... objdump
checking for ranlib... no
checking for ranlib... ranlib
checking for strip... no
checking for strip... strip
checking for windres... no
checking for windres... no
checking for windmc... no
checking for windmc... no
checking where to find the target ar... host tool
checking where to find the target as... host tool
checking where to find the target cc... just compiled
checking where to find the target c++... just compiled
checking where to find the target c++ for libstdc++... just compiled
checking where to find the target dlltool... host tool
checking where to find the target gcc... just compiled
checking where to find the target gcj... just compiled
checking where to find the target gfortran... just compiled
checking where to find the target ld... host tool
checking where to find the target lipo... host tool
checking where to find the target nm... host tool
checking where to find the target objdump... host tool
checking where to find the target ranlib... host tool
checking where to find the target strip... host tool
checking where to find the target windres... host tool
checking where to find the target windmc... host tool
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether -fkeep-inline-functions is supported... yes
configure: creating ./config.status
config.status: creating Makefile

20. Now my gccbuild folder contains : config.log config.status Makefile serdep.tmp
21. Typed make
22. a lot of "checking" lines later I got this:
Configuring stage 1 in ./mpfr
configure: WARNING: unrecognized options: --enable-threads, --enable-checking, --disable-libunwind-exceptions, --enable-languages, --disable-intermodule, --enable-checking, --disable-coverage, --enable-languages
configure: creating cache ./config.cache
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for none-pc-linux-gnu-strip... no
checking for strip... strip
configure: WARNING: using cross tools not prefixed with host triplet
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
configure: error: source directory already configured; run "make distclean" there first
make[2]: *** [configure-stage1-mpfr] Error 1
make[2]: Leaving directory `/home/username/gccbuild'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/username/gccbuild'
make: *** [all] Error 2

23. went to the gcc-4.4.2/mpfr/ directory
24. typed "su" and logged in as root user
25. ran "make distclean"
26. Ctrl+d
27. entered the gccbuild folder
28. typed "make distclean"
29. Deleted the rest of the files in the folder
30. ran ../gcc-4.4.2/configure --prefix=/usr/local --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-checking=release --disable-libunwind-exceptions --with-gmp=/usr/share/doc/gmp-4.2.2
31. typed make
32. The build process started at 13:15 hrs
33. Build completed 14:19 hrs with the final lines as:
make[5]: Leaving directory `/home/username/gccbuild/i686-pc-linux-gnu/libgomp'
/home/username/gccbuild/./gcc/gfortran -B/home/username/gccbuild/./gcc/ -B/usr/local/i686-pc-linux-gnu/bin/ -B/usr/local/i686-pc-linux-gnu/lib/ -isystem /usr/local/i686-pc-linux-gnu/include -isystem /usr/local/i686-pc-linux-gnu/sys-include -g -O2 -Wall -fsyntax-only omp_lib.f90
make[4]: Leaving directory `/home/username/gccbuild/i686-pc-linux-gnu/libgomp'
make[3]: Leaving directory `/home/username/gccbuild/i686-pc-linux-gnu/libgomp'
make[2]: Leaving directory `/home/username/gccbuild/i686-pc-linux-gnu/libgomp'
make[1]: Leaving directory `/home/username/gccbuild'

34. You can optionally run some tests as specified here: http://gcc.gnu.org/install/test.html
35. Otherwise, in the gccbuild directory, type "su"
36. Log in as root user
37. Type 'make install'
38. The installation procedure will begin. For me, it took two to three minutes.
39. That's it! gcc is installed in your system. You can log out of root with Ctrl+d
40. Type "gcc -v" and you'll see the new version number of gcc Enjoy!!!

Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.4.2/configure --prefix=/usr/local --enable-threads=posix --mandir=/usr/share/man --infodir=/usr/share/info --enable-checking=release --disable-libunwind-exceptions --with-gmp=/usr/share/doc/gmp-4.2.2
Thread model: posix
gcc version 4.4.2 (GCC)

Tried make -k check. It showed "PASS" for many tests and then came to a part where it needed overwriting permissions. So I pressed Ctrl+C, logged in with 'su' and ran "make -k check" again. This time, it gave me:

Collector appears to work
Completed 368 collections
PASS: gctest
==================
All 1 tests passed
==================