Tag Archives: Java

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!