Netbeans IDE Look & Feel under Ubuntu 12.04

Whatever issue you’ve got with the Look & Feel in Ubuntu 12.04 PP, running Netbeans, you can set the LAF native look & Feel instead of the GTK one (which has by the way several issues under Linux).


SOLUTION 1

Go to your netbeans directory (ex: /home/user/netbeans7.2/etc) and open the file : netbeans.conf

then add the following line to netbeans options:
-J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd --laf Metal


# ${HOME} will be replaced by JVM user.home system property
 netbeans_default_userdir="${HOME}/.netbeans/7.1.2"

# Options used by NetBeans launcher by default, can be overridden by explicit
 # command line switches:
 netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd --laf Metal"
 # Note that default -Xmx and -XX:MaxPermSize are selected for you automatically.
 # You can find these values in var/log/messages.log file in your userdir.
 # The automatically selected value can be overridden by specifying -J-Xmx or
 # -J-XX:MaxPermSize= here or on the command line.

# If you specify the heap size (-Xmx) explicitly, you may also want to enable
 # Concurrent Mark & Sweep garbage collector. In such case add the following
 # options to the netbeans_default_options:
 # -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled
 # (see http://wiki.netbeans.org/FaqGCPauses)

# Default location of JDK, can be overridden by using --jdkhome :
 netbeans_jdkhome="/usr/lib/jvm/jdk1.7.0"

# Additional module clusters, using ${path.separator} (';' on Windows or ':' on Unix):
 #netbeans_extraclusters="/absolute/path/to/cluster1:/absolute/path/to/cluster2"

# If you have some problems with detect of proxy settings, you may want to enable
 # detect the proxy settings provided by JDK5 or higher.
 # In such case add -J-Djava.net.useSystemProxies=true to the netbeans_default_options.

Start Netbeans and it should look like this:

Netbeans 7.1.2

Remark:
You can achieve the same result running netbeans with sudo command:

sudo sh /home/youruserhomename/netbeans-7.2.1/bin/netbeans

But this is not recommended.

Or by running netbeans with LAF parameter:


/bin/sh /home/youruserhomename/netbeans-7.2.1/bin/netbeans -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd --laf Metal


SOLUTION 2:

if you really want to keep the GTK look and feel for netbeans, then you have to modify the default general interface font in Ubuntu :

To something else than Ubuntu regular font which is bolder than the other usual fonts. Choose Sans or Droid Sans.

gsettings set org.gnome.desktop.interface font-name 'Droid Sans 11'


SOLUTION 3:


remove buggy unicode fonts, in order to use GTK look and feel.

sudo apt-get remove fonts-unfonts-core

Run Netbeans 7.1.2  from your Terminal typing only : netbeans  instead of the long path:

Create a file and name it netbeans and append the following (And modify the Netbeans home directory to yours):

#!/bin/sh
NETBEANS_HOME="/home/hanynowsky/netbeans-7.1.2"
$NETBEANS_HOME/bin/netbeans $*

And finally put this file in /usr/bin/

Once done, press ALT+F2 , type netbeans and press ENTER

Netbeans command Run

Netbeans command Run

About these ads

37 thoughts on “Netbeans IDE Look & Feel under Ubuntu 12.04

    1. Hanynowsky Post author

      It should definitely work. Unless you’re using a different JDK like OpenJDK which I suspect not to include Metal Laf. (I am not sure). I am using Sun JDK 1.7
      And what’s the result of running your netbeans with sudo ?

      Reply
      1. Jirka

        It does not work here either. First, the etc directory is not in ~/.netbeans/7.1.2. I created it and copied the netbeans.conf file from /usr/local/netbeans-7.1.2/etc/netbeans.conf. But it still did not activate the Metal LF.

        Reply
        1. Hanynowsky Post author

          Ok. May I know something? How did you install Netbeans? From Software Center? Or you downloaded it from netbeans.org and installed it with shell installer?

          Reply
        2. Jirka

          Now it works. (1) the missing etc user directory is normal, it does not exist by default, one just need to create the directory and file, or edit the global one as I did. (2) seems that Metal and Gtk is the same thing under Java 7, but I used Nimbus (–laf javax.swing.plaf.nimbus.NimbusLookAndFeel) and it works. Well, I don’t like the laf at all, but at least I can see the menus.

          Reply
          1. Hanynowsky Post author

            The only LAF that does not have issues in a Gnome environment is Metal.
            You can run netbeans from Terminal using this command:
            netbeans -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd --laf Nimbus or netbeans -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd --laf Metal

            The Classes for LAFs are:
            GTK: com.sun.java.swing.plaf.gtk.GTKLookAndFeel
            & Metal : javax.swing.plaf.metal.MetalLookAndFeel
            If you can’t run NetBeans from line command, then create a file and name it netbeans and append the following (And modify the Netbeans homes directory to yours):

            #!/bin/sh
            export NETBEANS_HOME="/home/hanynowsky/netbeans-7.1.2"
            $NETBEANS_HOME/bin/netbeans $*
            

            And finally put this file in /usr/bin/

  1. Guilherme Salazar

    Another possible fix:

    - Edit the gtkrc file for the Ambiance theme (or the one you’re using and having the issue)
    sudo vim /usr/share/themes/Ambiance/gtk-2.0/gtkrc

    - Go to line 338
    press the ‘:’ key with control pressed, type 338 and press enter

    - The line 338 is
    style “menu” {

    Substitute this to
    style “menu” = “black” {

    - Save

    Happy coding! :)

    (found at http://forums.netbeans.org/topic47823.html)

    Reply
    1. Hanynowsky Post author

      Thanks @Guilherme :) I appreciate it! I came across this same hack before and it actually made my ambiance theme look ugly in some parts in other applications. I don’t remember.
      So I reverted back to vanilla Ambiance.
      However, not only the menus are concerned, FONT and The Whole Look and Feel.
      GTK+ LAF applied to Java Applications in Ubuntu is broken to some degree. Unfortunately this wouldn’t be fixed untill Java 8 is released.

      Reply
      1. Guilherme Salazar

        Hi, @Hanynowsky,
        I see, I’ve also noticed this ugliness.
        But why won’t it be fixed until Java 8 release?

        Reply
  2. HopeThisHelps

    I manged to fix mine without having to use the hideous Metal theme.

    After downloading/installing 7.1.2 from the website, I downloaded netbeans 7.0.1 using ubuntu software center.

    I used the netbeans.conf in /usr/share/netbeans/7.0.1/etc, replacing the one in /usr/local/netbeans-7.1.2/etc.

    Make sure you backup before replacing!

    Note: I also have the “menu” = “dark” { fix in place, I don’t know if that helped.

    Reply
    1. Hanynowsky Post author

      Cool! yet, the “menu” = “dark” or “menu”=”black” only changes the color of Netbeans menus to be visible). The purpose here is to use the Netbeans 7.1.2 with a correct look. The GTK look is broken, not only for Netbeans, but for all Applications in Java. If you develop Swing Applications, you will notice this.

      Reply
  3. illuvitar1890

    I was able to get this to work perfectly on a fresh NB install by adding “-J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd” to my netbeans.conf file (as you say to do) and by changing the line in /usr/share/themes/Ambiance/gtk-2.0/gtkrc that says ‘style “menu” {‘ to ‘style “menu” = “dark” {‘. Hope this helps someone else!

    Reply
  4. ninux

    I had installing Oracle JRE 1.7.0 for 64bit, trying to load netbeans 7.2 with Metal and adding some options from you. Netbeans still make unity hang and can’t typing any character from the keyboard. Force me to press CTRL ALT F1 and kill the java process. :)

    Reply
    1. ninux

      Updating my comments. I should wait for 15 seconds before using NetBeans and everything seems OK. Java need times to warm up netbeans. Just like a diesel engine car :).

      Reply
    2. Hanynowsky Post author

      Indeed, Netbeans is like a skyrocket. When launched, the whole computer is shaking!
      In fact, you have to wait for the Java VM to load and for Netbeans to scan your opened projects as just connect to maven/team repositories if enabled…..For me it varies between 7 and 16 seconds. And the more RAM you have, the faster Netbeans boots. Besides, later on, get yourself an SSD hard disk, whill reduce the boot time by 2 (7 seconds instead of 15). Happy programming ;)

      Reply
    1. Hanynowsky Post author

      Thanks. I still did not modify the post.
      I have been watching the same bug under the name of (hanynowsky) and been aware of the solution.
      Thanks for reminding us. Cheers.

      Reply
  5. meddyniho

    opening netbeans with –laf metal parameteres worked perfectly fine for me .. thanks a lot mate :D ..

    slightly off topic: i want to run netbeans in sudo mode .. well i just have to for a stupid reason .. how do i do that without having to enter password everytime .. i am trying to modify netbeans.desktop file so that i can run it in sudo mode i have tried putting sudo to the start of “exec” line but after that netbeans.desktop stops working :( ..

    Reply
    1. Hanynowsky Post author

      You’re welcome.
      You need to add an exception in your SUDOERS file.
      Like this:
      type in Terminal : sudo -E visudo
      and add at the end of the file, the line:
      %yourusername ALL=(ALL) NOPASSWD: /sbin/shutdown
      and save.
      this will allow you to run the shutdown command without being prompted for a password.
      Replace the /sbin/shutdown by the path to your netbeans executable and you’re done.

      Reply
  6. Peter

    The original fix works, but at first I simply added the line, and it didn’t work. Then I looked very hard and noticed it ALL has to be within the quotes.
    Once I made the new line within the quotes, and saved it, and restarted netbeans 7.02 it worked just fine. The Metal view is good enough.
    Thanks……….

    Reply
  7. Pingback: Netbeans IDE no Ubuntu 12.04, problemas visuais [resolvido] | Luiz Souza

    1. Hanynowsky Post author

      You should not. Java LAF is the ugliest out there.
      Even JavaFX is still behind.
      This post just indicates how to change the LAF in Netbeans. You have limited possibilities: Metal, Nimbus & GTK. If you’re happy with Netbeans GTK under Linux then go ahead.
      and Metal LAF can be customized somehow. See IntellijIdea 12.

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s