Saturday, 22 July 2017

NetBeans on CentOS 7

The default appearance of NetBeans on Linux is not so good. Here are some settings you can use to improve it.

Menu Appearance


When using the GTK look and feel with the default GNOME Shell Adwaita theme popup menus are drawn without borders. This can be fixed by installing the NetBeans plugin from https://bitbucket.org/neugens/netbeans-gtk-laf-menu-fix.

Recommended GNOME Shell font settings


Font settings can be changed using gnome-tweak-tool. I recommend “DejaVu Sans Book” for the interface and “DejaVu Sans Mono Book” for monospace. These fonts render well on Linux and include a large number of Unicode characters. Use “Slight” hinting and “Rgba” anti-aliasing for LCD monitors.

In addition create the file $HOME/.config/fontconfig/fonts.conf and run the command fc-cache:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <match target="font">
  <edit mode="assign" name="rgba">
   <const>rgb</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hinting">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hintstyle">
   <const>hintslight</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="antialias">
   <bool>true</bool>
  </edit>
 </match>
  <match target="font">
    <edit mode="assign" name="lcdfilter">
      <const>lcddefault</const>
    </edit>
  </match>
</fontconfig>


OpenJDK with patches


JetBrains, the creators of the IntelliJ IDEA IDE, maintain a version of OpenJDK patched for better font rendering on Linux. This can be downloaded from https://bintray.com/jetbrains/intellij-jdk.

The default JDK used for rendering NetBeans can be set in the NetBeans installation directory in file “netbeans-8.2/etc/netbeans.conf”: 

netbeans_jdkhome="/home/stephen/Apps/openjdk-jetbrains"

Also in netbeans.conf add the following to netbeans_default_options: 

-J-Dswing.aatext=TRUE -J-Dawt.useSystemAAFontSettings=on

NetBeans font settings


In NetBeans Options→Fonts & Colors be sure to select “Monospace” to avoid a bug where Japanese characters are not rendered.

For my taste the default line spacing is too big. To match the line spacing used by Sublime Text edit the file $HOME/.netbeans/8.2/config/Editors/Preferences/org-netbeans-modules-editor-settings-CustomPreferences.xml and add the lines:

<entry javaType="java.lang.Float" name="line-height-correction" xml:space="preserve">
    <value><![CDATA[0.9]]></value>
</entry>

No comments:

Post a Comment