Show Java Type in Eclipse Package Explorer

Jealous of IntelliJ IDEA? Want to see what’s in a file without opening up every one of them? Well, it’s completely possible to show the Java Type in the Eclipse Package Explorer too! Though it’s not enabled by default.

List of available java type decorators

Showing Java types in the Eclipse Package Explorer

To enable it, navigate to Window > Preferences in the menubar to open the preferences window. Then go to General > Appearance > Label Decorations and check Java Type Indicator in the list of available label decorations.

No FXML File specified: @FXMLController annotation not detected in an OSGi environment

Currently I’m developing an OSGi application using JavaFX and DataFX. Unfortunately DataFX is not an OSGi bundle, so I’m currently wrapping it as a bundle myself. During development I’ve ran into a few problems, one of them being that the @FXMLController was not being detected, throwing an FxmlLoaderException with the message “No FXML File specified!

The solution is actually really simple, be sure to include the  org.datafx.controller  bundle in the bundle where your classes live that use the @FXMLController annotation. Now your annotations are actually correctly loaded by the Classloader and allows the  ViewFactory class, responsible for loading the FXML using the @FXMLController value, to actually detect the annotation.

tl;dr include the org.datafx.controller bundle in your own bundle.

BONUS FACT You can actually skip the @FXMLController annotation detection by having your controller end with “Controller” e.g. MyFooController and give your FXML file the same name, only without “Controller” e.g. for MyFooController I would name my fxml file MyFoo.fxml.

Loading FXML in an OSGi Environment

tl;dr use FXMLLoader.setDefaultClassLoader(Activator.class.getClassLoader());

When loading an .fxml file using FXMLLoader one might run into an ClassNotFoundException similar to the following:

Caused by: javafx.fxml.LoadException: /nl/mikero/MyApplication.fxml:8
.. stacktrace …
Caused by: java.lang.ClassNotFoundException: nl.mikero.MyApplicationController

This is because the FXMLLoader uses a different Classloader. So while you can reach say ApplicationController in your code, FXMLLoader can not. Fortunately, since JavaFX 2.1 and thus JavaFX 8 the FXMLLoader class exposes a method setDefaultClassLoader() which, as the name suggests, you can use to make the FXMLLoader use a different Classloader.

Use the following line before loading your .fxml file to make FXMLLoader use the OSGi Classloader. I used the Activator class here, but any class in the bundle will do.

 

How to build KeePassX from source on Fedora 20

Here’s a short guide on how to build KeePassX from source on Fedora 20 in addition to the official OS specific instructions for Ubuntu and Mac OS. Looking to build KeePassX on openSUSE 13.1? Check out my other post How to build KeePassX from source on openSUSE 13.1.

  1. Download the source from the KeePassX website or clone their git repository. I decided to clone the github repository:
  2. Make sure the following packages are installed: cmake, gcc, gcc-c++, qt-devel, libgcrypt-devel.x86_64 by running the following as root:
  3. Now we should finally be able to compile the source:
  4. If everything succeeded, we can now install KeePassX:
  5. That’s it! KeePassX should now be installed and ready to use!

How to build KeePassX from source on openSUSE 13.1

Here’s a short guide on how to build KeePassX from source on Fedora 20 in addition to the official OS specific instructions for Ubuntu and Mac OS.

  1. Download the source from the KeePassX website or clone their git repository. I decided to clone the github repository:
  2. Make sure the following packages are installed: cmake, libqt4-devel, libgcrypt-devel, by running the following as root:
  3. Now we should finally be able to compile the source:
  4. If everything succeeded, we can now install KeePassX:
  5. That’s it! KeePassX should now be installed and ready to use!