8

Is there a patched version of OpenJDK-8 or Oracle JDK 8 for Ubuntu 14.10 which fixes ugly fonts in Java Applications (Jetbrains products, Netbeans etc.)?

I had previously installed a patched version of OpenJDK7 for Ubuntu 14.04 in this article, but it does not seem to be available for 14.10. I also could not find a patched version for OpenJDK8/OracleJDK8.

If there's any patched version or a patch for OpenJDK8/OracleJDK8 which I could install, I would really appreciate if anybody can point out.

Thank you.

1
  • Modern versions of IntelliJ bring their own JVM. Most likely to be able to handle things like this. Nov 16, 2016 at 8:35

5 Answers 5

9

After reading various tutorials and messing with a bunch of fixes I've found a way that works perfectly.

First of all download JDK 8 from Oracle and execute the following lines in the terminal:

cd Downloads
tar -xvf jdk-8u25-linux-x64.tar.gz
rm jdk-8u25-linux-x64.tar.gz
sudo mkdir -p /usr/lib/jvm/
sudo mv jdk1.8.0_25 /usr/lib/jvm/

Now download the JDK font fix (Courtesy of Urshulyak Yaroslav) by executing the following:

cd ~/Downloads
wget http://urshulyak.com/jdk-8u5-tuxjdk-b08.tar.gz
tar -xvf jdk-8u5-tuxjdk-b08.tar.gz
sudo mv jdk-8u5-tuxjdk-b08 /usr/lib/jvm
rm jdk-8u5-tuxjdk-b08.tar.gz

This will extract the downloaded zip and move it to /usr/lib/jvm/. Now run the following in the terminal:

cd ~
sudo gedit .bashrc

Then add the following lines to the very bottom of the bashrc file.

JAVA_HOME=/usr/lib/jvm/jdk1.8.0_25/
export JAVA_HOME

Save it then gedit the idea.sh. (Your script location may be different)

gedit /home/USER/Downloads/idea/bin/idea.sh

At the very bottom of the script replace the line(s) in the While Do statement at the bottom with these two lines:

eval "/usr/lib/jvm/jdk-8u5-tuxjdk-b08/bin/java" $ALL_JVM_ARGS -Djb.restart.code=88 $MAIN_CLASS_NAME "$@"
test $? -ne 88 && break

Save it then open up IntelliJ, the fonts should work and you will be using Oracle JDK 8 for development. You will likely have to edit Project Settings and set up your JDK again but be sure to use the actual JDK and not the font fix one.

This fix also works with CLion, Android Studio and PyCharm.

These instructions assume the JDK version was 1.8.0_25, file/path names will change for future versions.

5
  • Thank you for detailed answer. I tried your solution, but my fonts became larger and bolder. I could decrease the font size, but could not change bold fonts to normal.
    – Deepal
    Dec 29, 2014 at 13:03
  • Yeah, the size is increased, to 14 (I changed mine to 11) but my fonts weren't bold? I assume you tried the other fonts to see if they were still bold?
    – user282577
    Dec 29, 2014 at 15:53
  • Yup.Not all fonts are bold.The font I am currently using became bold. I think I might have to live with that. Is there any way this solution can be applied to all java applications other than modifying their executables? I mean to jar files as well? Can't I use this patched jdk as my default jdk?Isn't it a full jdk?
    – Deepal
    Dec 29, 2014 at 17:39
  • 1
    Sorry I cant help with the bold fonts. You could maybe try downloading another copy of the font, worth a shot if it bothers you that much. You can try messing around with the font fix, I had some issues using it as my JDK, you could try downloading the full openJDK and merging the two, that could work.
    – user282577
    Dec 29, 2014 at 19:05
  • 3
    @Deepal Make sure you are setting also export _JAVA_OPTIONS="-Dawt.useSystemAAFontSettings=lcd -Dsun.java2d.xrender=true" in your bashrc
    – Salem
    Jan 21, 2015 at 15:13
1

To make DanielSteward anwser complete:

Unfortunately tuxjdk for GTK look and feel uses font set in currently used gtkrc. But most of the themes don't set any font there. As a result netbeans will use bold Arial 15 as UI font.

To fix that create gtkrc just for netbeans with fixed font and tell netbeans to use this file.

I prepared special launcher that does this semi-automatically:


#!/bin/bash

### Customizable variables: ###

# Path where netbeans was installed
NETBEANS_PATH=${NETBEANS_PATH:-~/opt/netbeans-dev-2015-06-04}/bin/netbeans
# Desktop environment name to use style from
USED_DE=${USED_DE:-mate}
# Tuxjdk seems to render too big UI fonts so use this value to decrease them
FONT_SUBTRAHENT=${FONT_SUBTRAHENT:-3}

###############################

function remQuotes(){
  echo "${@//\'/}"
}

function decreaseFontSize(){
  local subtrahend=$1; shift
  local args="$@"
  echo ${args//[0-9]/} $((${args//[!0-9]/} - $subtrahend))
}

theme=$(remQuotes `gsettings get org.${USED_DE}.interface gtk-theme`)
font=$(remQuotes `gsettings get org.${USED_DE}.interface font-name`)
font=$(decreaseFontSize $FONT_SUBTRAHENT $font)

themeDirs=$(find ~/.themes/ /usr/share/themes/ -type d -name "${theme}")
gtkRcPath=""
for dir in "$themeDirs"; do
  if [[ -f "$dir/gtk-2.0/gtkrc" ]]; then
    gtkRcPath="$dir/gtk-2.0/gtkrc"
    break;
  fi
done

if [[ "$gtkRcPath" == "" ]]; then
  echo "Theme not found" >/dev/stderr
  ./$NETBEANS_PATH $@
fi

cat  $HOME/.netbeans/.gtkrc-2.0
include "$gtkRcPath"

style "user-font" {
    font_name = "$font"
}

widget_class "*" style "user-font"

gtk-font-name="$font"

EOF

GTK2_RC_FILES=~/.netbeans/.gtkrc-2.0 $NETBEANS_PATH $@

This will read your theme settings and create fake theme just for netbeans. You have to adjust NETBEANS_PATH and USED_DE variables to your environment.

0

I've built Openjdk 8u40 on my own and applied tuxjdk patches. Moreover, i had to create a file called local.conf in /etc/fonts/ to override java's fontmap for its logical fonts like Dialog, Monospaced, etc. After that, Swing based applications improved a lot. Take a look HERE.

0

At the moment there are only rpm packages for tuxjdk: http://download.opensuse.org/repositories/home:/TheIndifferent:/tuxjdk/

I need little more time to learn about debian packaging and prepare proper packages, plus document some interesting features of version 03 of tuxjdk. So stay tuned, and please report any issues you're facing with tuxjdk to https://github.com/TheIndifferent/tuxjdk , so I will be able to reproduce and (hopefully) fix them.

0

Actually you don't need to bother modifying idea.sh, which is volatile under updates. There is a user-specific configuration file, ~/.IntelliJIdea2016.1/config/idea.jdk (the namings change accordingly), which stores the boot JDK.

Official references:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.