Install JDK 1.8.0_74 in Linux

This is for 64-bit installation.

  1. Download JDK from Oracle site
    http://www.oracle.com/technetwork/java/javase/downloads
    The installation file I use is jdk-8u74-linux-x64.tar.gz.
  2. Change directory to install the JDK code in /opt
    cd /opt
  3. extract the JDK files
    sudo tar -xvzf <location of downloaded JDK>/jdk-8u74-linux-x64.tar.gz 

    This will put the JDK into the newly created directory named jdk1.8.0_74

  4. Update environment variables to point to the newly installed JDK by editing the /etc/environment file.
    sudo nano /etc/environment

    Add the JAVA_HOME variable, and add JDK bin to the PATH variable.

    JAVA_HOME="/opt/jdk1.8.0_74"
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/jdk1.8.0_74/bin" 
  5. Refresh the environment variable.
    source /etc/environment
  6. Verify that the updated environment variables are in place and the path to the JDK is valid
    $ echo $JAVA_HOME
    /opt/jdk1.8.0_74
    $ echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/jdk1.8.0_74/bin
    $ javac -version
    javac 1.8.0_74
  7. Update Java alternative list. You want to set a higher priority for the new JDK. On my system this is the result when I query the alternatives:
    $ update-alternatives --verbose --query java
    Link: java
    Status: auto
    Best: /usr/lib/jvm/java-6-openjdk/jre/bin/java
    Value: /usr/lib/jvm/java-6-openjdk/jre/bin/java
    
    Alternative: /usr/lib/jvm/java-6-openjdk/jre/bin/java
    Priority: 1061
    Slaves:
     java.1.gz /usr/lib/jvm/java-6-openjdk/jre/man/man1/java.1.gz
    

    So, let’s make the new JDK our default…

    sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_74/bin/java 18074

    The response is:

    update-alternatives: using /opt/jdk1.8.0_74/bin/java to provide /usr/bin/java (java) in auto mode.

    Now, when you type java -version, you will see

    java version "1.8.0_74"
    Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
    Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)
  8. Likewise, set the new Java compiler as default with

    sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_74/bin/javac 18074
  9. If you are running Firefox, you can go on to link the new JRE plugin to your Mozilla plugins folder. See my other post on how to activate the JRE plugin for Firefox.

Changing Display Font in elementary OS’s pantheon Terminal

Edit the font property in the org.pantheon.terminal.settings schema. For example:

gsettings set org.pantheon.terminal.settings font 'DejaVu Sans Mono'

Then close and reopen the terminal for the change to take effect.

You can find the correct font name with the following command:

fc-list | cut -f2 -d: | sort -u

Changing Display font in XTerm and UXTerm

Edit .Xresources to set the desire True Type font for UXTerm and XTerm.

XTerm*renderFont: true
XTerm*faceName: DejaVu Sans Mono
XTerm*faceSize: 10

UXTerm*renderFont: true
UXTerm*faceName: DejaVu Sans Mono
UXTerm*faceSize: 10

Use xrdb to merge your setting into the X server resource database.

xrdb -merge ~/.Xresources

Use xrdb -q to query the resulting resource setting:

$ xrdb -q
*customization: -color
UXTerm*faceName:        DejaVu Sans Mono
UXTerm*faceSize:        10
UXTerm*renderFont:      true
XTerm*faceName: DejaVu Sans Mono
XTerm*faceSize: 10
XTerm*renderFont:       true
Xcursor.size:   18
Xcursor.theme:  DMZ-White
Xcursor.theme_core:     true

You can find the correct font name with the following command:

fc-list | cut -f2 -d: | sort -u

Set Up Proxy Environment Variables

Add the following one-liner at the end of .bashrc script:

export {http,https,ftp}_proxy='http://<user>:<password>@<proxy-server>:<port>'

For example: export {http,https,ftp}_proxy='http://10.0.2.2:3128'

For this to take effect, restart terminal or run source with . ~/.bashrc

After that, check for the presence of the environmental variables with printenv | grep proxy

yields the following output:

http_proxy=http://10.0.2.2:3128
ftp_proxy=http://10.0.2.2:3128
https_proxy=http://10.0.2.2:3128

GNU Emacs error on elementary OS

Problem: GNU Emacs-24 crashes at startup on elementary OS. This is due to incompatibility between the graphical toolkit used in the Emacs package.

X protocol error: BadMatch (invalid parameter attributes) on protocol request 139
When compiled with GTK, Emacs cannot recover from X disconnects.
This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715
For details, see etc/PROBLEMS.
Fatal error 6: Aborted
Backtrace:
emacs[0x4f74cb]
emacs[0x4dcf3e]
emacs[0x4f7513]
emacs[0x4b219b]
emacs[0x4b420c]
emacs[0x4b426d]
/usr/lib/x86_64-linux-gnu/libX11.so.6(_XError+0x12b)[0x7f78f57b654b]
/usr/lib/x86_64-linux-gnu/libX11.so.6(+0x3b5e7)[0x7f78f57b35e7]
/usr/lib/x86_64-linux-gnu/libX11.so.6(+0x3b695)[0x7f78f57b3695]
/usr/lib/x86_64-linux-gnu/libX11.so.6(_XReply+0x1e8)[0x7f78f57b4578]
/usr/lib/x86_64-linux-gnu/libX11.so.6(+0x325e0)[0x7f78f57aa5e0]
...
Aborted (core dumped)

Solution: Setting the environment variable XLIB_SKIP_ARGB_VISUALS=1 allows Emacs to start. So use this command line to start Emacs in the terminal:

XLIB_SKIP_ARGB_VISUALS=1 emacs

Or better yet, create a launcher in ~/.local/share/applications by copying the emacs24.desktop file, and change the Exec line to

Exec=/usr/bin/env XLIB_SKIP_ARGB_VISUALS=1 /usr/bin/emacs24 %F

See [Adding Desktop Entries to System] for more information on desktop files.