Category Archives: Ubuntu

Setting up Java developmment environment in Ubuntu – Gnome

Having struggled to set up a working and decent looking Java environment in Ubuntu (Linux), here’s my attempt at collating few steps/tweaks in one place.

These steps are scattered out there on the net, but it’s helpful to have it in one post.

On a freshly installed Ubuntu system these are the steps used to get up and running with Java development:

Hmm, but wait before diving into the Java specifics I first like to set the fonts a little smaller to my liking.

Using gnome-tweak-tool I prefer to set the fonts to something like the below:

Image

*Note Consolas may not be available on your system, so use something that you prefer for a terminal/editor font.

Setting up the JDK

Next, since I prefer Oracle JDK over the openjdk version I will go ahead and install that.

Unlike the openjdk* option, oracle jdk isn’t readily available in the ubuntu repo, so first add the PPA using the below:

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java7-installer

To set few environment variables just run this:

sudo apt-get install oracle-java7-set-default

To confirm the installation worked.
Run

java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

Setting up Eclipse

Download eclipse from eclipse.org

At the time of this writing the latest for linux (64bit) version is:

eclipse-jee-kepler-SR2-linux-gtk-x86_64.tar.gz

Once downloaded extract it into your preferred location!

Run eclipse by going to eclipse home directory (extracted folder location) and you should have a working eclipse ide!

Making Eclipse look Good in Linux/ Ubuntu

Now, there is one more bit of tweak needed to make this eclipse look good on ubuntu (By default the font/tabs would appear bigger than the windows counterpart).

To make Eclipse look more compact use .gtkrc-2.0 file as described below.

Create a file named .gtkrc-2.0 in your ~ (Home directory) with the following contents:

style "gtkcompact" {
GtkButton::default_border={0,0,0,0}
GtkButton::default_outside_border={0,0,0,0}
GtkButtonBox::child_min_width=0
GtkButtonBox::child_min_heigth=0
GtkButtonBox::child_internal_pad_x=0
GtkButtonBox::child_internal_pad_y=0
GtkMenu::vertical-padding=1
GtkMenuBar::internal_padding=0
GtkMenuItem::horizontal_padding=4
GtkToolbar::internal-padding=0
GtkToolbar::space-size=0
GtkOptionMenu::indicator_size=0
GtkOptionMenu::indicator_spacing=0
GtkPaned::handle_size=4
GtkRange::trough_border=0
GtkRange::stepper_spacing=0
GtkScale::value_spacing=0
GtkScrolledWindow::scrollbar_spacing=0
GtkTreeView::vertical-separator=0
GtkTreeView::horizontal-separator=0
GtkTreeView::fixed-height-mode=TRUE
GtkWidget::focus_padding=0
}
class "GtkWidget" style "gtkcompact"

style "compact-toolbar"
{
GtkToolbar::internal-padding = 1
xthickness = 2
ythickness = 2
}

style "compact-button"
{
xthickness = 1
ythickness = 1
}

class "GtkToolbar"                   style "compact-toolbar"
widget_class "*<GtkToolbar>*<GtkButton>"    style "compact-button"

Now restart eclipse and your IDE should look a little better!

To reduce the tab size of Eclipse you will need to edit a file which is found under eclipse as described below:

Find the file called e4_default_gtk.css under your eclipse installation folder:

Example location: eclipse/plugins/org.eclipse.platform_<ur eclipse version>/css/e4_default_gtk.css

Change the .MPartStack font-size from 11 or whatever value to a 9

Example:

.MPartStack {
	font-size: 9;
	swt-simple: false;
	swt-mru-visible: false;
}

Before all the tweaks how Eclipse appears:

Image

After the tweaks applied:

Image

That should complete the settings needed to have a working (and good looking in my opinion) Eclipse – Java development environment in Ubuntu.

I have been using ubuntu 13 and Ubuntu 14 versions so far and the options above have worked for me.

Hope this helps someone!

Restoring ubuntu grub in dual boot

With the proliferation of linux variants out there, i couldn’t resist the temptation to try out yet another one of the ubuntus, mints, or the fedoras…

But installing a second/third OS next to the default meant loosing out on the already installed GRUB/Boot options during a dual boot.

Note: The scenario below is with all boot options still appearing. Not where your boot option is missing, there are many posts out there which explain that using live cd/usb.

Here’s what I had: Windows 7, Ubuntu 11.10. (Dual boot).

Now, I installed Linux Mint 12 after it’s recent jump in rankings. But this changed the GRUB of ubuntu (earlier one) to the one provided by Mint with default choice as Mint.

So i booted in ubuntu and just fired off these commands in sequence.

sudo update-grub

sudo grub-install /dev/sda

That’s it! rebooted and voila the purple GRUB2 loader was back 🙂