Caprica Software

vlcj 4.x Tutorial

First Steps

The first step when developing a vlcj application is to make sure vlcj can find the LibVLC native libraries. These native libraries provide the public API to LibVLC and is what enables you to embed VLC media players in your own applications.

In most cases, vlcj will be able to find the installed native libraries without you needing to do anything in your own code. This will likely be the case when you have VLC installed into the default location on your computer. If so, vlcj will be able to find the native libraries just by using your computer's normal search path.

Nevertheless, the most common problem for new developers when using vlcj is how to properly locate these libraries, and this tutorial will show you how to do just that.

Native Discovery

The previous version of vlcj provided a NativeDiscovery class that you could optionally use to try and located and setup the VLC native libraries.

If you wanted to use this native discovery, you had to explicitly code it in your application.

With vlcj-4, this native discovery is now intrinsic to the MediaPlayerFactory class, you do not have to invoke it yourself in your own code.

This should "just work" for most applications the vast majority of the time, especially so if VLC has been installed using the ordinary operating system package installation process.

The following code should be all that is needed to initialise LibVLC:
public class Tutorial {
public static void main(String[] args) {
MediaPlayerFactory factory = new MediaPlayerFactory();

There is nothing special here.

If you are using an EmbeddedMediaPlayerComponent, then it will create the media player factory for you:
public class Tutorial {
public static void main(String[] args) {
EmbeddedMediaPlayerComponent mediaPlayerComponent = new EmbeddedMediaPlayerComponent();

Recent versions of vlcj can be configured to look in a specific directory for a VLC installation.

This can be configured by creating a vlcj.config file in the ~/.config/vlcj directory, for example:


There are various other discovery directory providers included with vlcj, check the Javadoc for more information.

FIXME maybe do an extra tutorial on discovery options

Discovery Not Working?

If this does not work for you, you may need to consider using a bespoke native discovery strategy, please consult the Javadoc for more information.

You must be able to successfully create this media player factory before you can do anything else with vlcj.