Eclipse Stuff

Eclipse Ubuntu Desktop Launcher

10 Dec 2014

Put the following in a file named $HOME/.local/share/applications/eclipse.desktop:

[Desktop Entry]
Version=4.4
Type=Application
Name=Eclipse Luna
Comment=Eclipse Luna
Icon=/home/mwood/eclipse-platform-4.4.1-linux-gtk-x86_64/icon.xpm
Exec=/home/mwood/eclipse-platform-4.4.1-linux-gtk-x86_64/eclipse -showlocation
Terminal=false
Categories=Development;IDE;Java;

Make sure to chmod +x $HOME/.local/share/applications/eclipse.desktop, then open the idea.desktop from within the graphical file manager. Then, once launched, right-click on the icon in your Ubuntu taskbar and select "Lock to Launcher".

Eclipse Platform Runtime Binary

27 May 2014

Instead of downloading from http://www.eclipse.org/downloads/, which is only packaged versions of Eclipse, consider downloading the Eclipse Platform Binary instead, and adding only the packages that you need.

If you go to http://download.eclipse.org/eclipse/downloads/ and click on the link to the latest stable build, the next page will have a section called "Platform Runtime Binary". Download that, and you will have a much leaner Eclipse experience. In particular, this allows you to avoid git integration, if you know you will only be using git on the command line anyway.

Using Eclipse Luna as an example, here are the things I always install on top of Eclipse Platform Runtime Binary:

Work With Name Work With URL Item
Luna http://download.eclipse.org/releases/luna Programming Languages
-->Eclipse Java Development Tools
TestNG http://beust.com/eclipse TestNG
-->TestNG
Gradle http://dist.springsource.com/release/TOOLS/gradle Extensions / Gradle Integration
-->Gradle IDE
Groovy http://dist.springsource.org/release/GRECLIPSE/2.9.0/e4.4 Groovy-Eclipse (Required)
-->Groovy-Eclipse Feature

How to Run the JVM from a RAM Disk to Speed Up Eclipse

1 Dec 2014

Do all this as root.

Make a mount point for the ramdisk:

# mkdir /media/ramdisk-jdk1.7.0_67

Append to /etc/tmpfs:

tmpfs  /media/ramdisk-jdk1.7.0_67  tmpfs  defaults,mode=1777 0 0

Mount the ramdisk:

# mount -a

install squashfs

# apt-get install squashfs-tools

Make a sqashfs file out of your jdk:

# mksquashfs /usr/local/jdk1.7.0_67 /root/jdk1.7.0_67.sqsh

append to /etc/tmpfs:

# this line should already exist from the step above:
tmpfs  /media/ramdisk-jdk1.7.0_67  tmpfs  defaults,mode=1777 0 0

# this is the new line to append:
/root/jdk1.7.0_67.sqsh  /media/ramdisk-jdk1.7.0_67  squashfs  ro,defaults,loop 0 0

Use /media/ramdisk-jdk1.7.0_67/bin/java as your jdk!

In eclipse.ini, put the following two lines at the top:

-vm
/media/ramdisk-jdk1.7.0_67/bin

How to Add a License Header to the Top of Every New File

27 May 2014

Select the menu Window --> Preferences.

In the left-hand pane, navigate to Java --> Code Style --> Code Templates.

In the area on the right labeled "Configure generated code and comments:", navigate to Code --> New Java Files.

Click on New Java Files, and then hit the "Edit..." button to the right.

An "Edit Template" window will pop up.

The template currently looks like this in the editor window that is labeled "Pattern:"

${filecomment}
${package_declaration}

${typecomment}
${type_declaration}

Change it to look like this instead:

/*
 * My crazy license with unbelievable terms
 */
${filecomment}
${package_declaration}

${typecomment}
${type_declaration}

Click the "OK" button at the bottom of the "Edit Template" window to make it go away.

Click the "Apply" button at the bottom of the "Preferences" window.

Click the "OK" button at the bottom of the "Preferences" window.

Fixing Spaces and Tabs in Eclipse

Fixing spaces and tabs in Eclipse to be compatible with vi, Emacs, and all other 8-spaces-mean-one-tab editors and text utilities in the known universe.

Window --> Preferences --> Java --> Code Style --> Formatter.

In the "Select a profile:" drop-down, "Eclipse [built-in]" is probably selected. That's fine. Beside that drop-down is an "Edit..." button. Click that. An "Edit Profile 'Eclipse [built-in]'" dialogue box comes up.

On the "Indentation" tab (pardon the pun) at the top are "Tab policy", "Indentation size", and "Tab size"; change these to

Tab policy: Mixed
Indentation size: 4
Tab size: 8

You will be prompted to rename the profile. Choose a name like "8-space tab compatible"

Click "Apply" the "OK" and when you are returned to the "Formatter" section of the "Preferences" dialogue, ensure that you now have your new profile, "8-space tab compatible" selected. Press "Apply" and then "OK".

Removing Trailing Spaces from Java Code

9 December 2014

Window --> Preferences --> Java --> Editor --> Save Actions.

Check "Additional actions" checkbox.

Press "Configure..." button.

in "Code Organizing" tab, in "Formatter" subsection:

Check "Remove trailing whitespace" checkbox.

Check "All lines" radio button.

Press "OK" button.

Press "Apply" button.

Press "OK" button.