I want to use JavaFX in Ubuntu. According to this link, I have to install libavcodec53 and libavformat53. I googled and came across sites like this, which suggests to use

sudo apt-get update
sudo apt-get install libavcodec53

for Ubuntu 12.04 and 14.04. I am using 16.04 version and for me the above commands did not work.

I also used the below command

sudo apt-get install libav-tools

But when I gave sudo apt-cache search libav | grep extra-, it didn’t give me any result.

So how am I supposed to install libavcodec53 and libavformat53 so that I can use JavaFx in Ubuntu 16.04?

  • You don't need either to install libavcodec53 or libavformat53 anymore because since 16.04 JavaFX is included in the default Ubuntu repositories. – karel Dec 14 '17 at 14:47

You can either download JavaFX from the official Oracle website or install JavaFX from the default Ubuntu repositories.

Oracle JavaFX

As of JDK 7u6 JavaFX is included with the standard JDK and JRE bundles. Please download the JDK or JRE to use JavaFX. Oracle Java Installation instructions are at this question: How can I install Sun/Oracle's proprietary Java JDK 6/7/8 or JRE?.

On the same Oracle Java download page there is another link to download a Java SE Development Kit (JDK) Cobundle which contains JDK 8 with NetBeans IDE.


Ubuntu JavaFX

In the Ubuntu 16.04 and later default repositories JavaFX is packaged as a separate package named openjfx. To install it, open the terminal and type:

sudo apt install default-jdk openjfx  

This command is a complete alternative to installing Oracle Java and JavaFX. Optionally you can install openjdk-11-jdk instead of or alongside openjdk-8-jdk in Ubuntu 18.04, and openjfx works with both JDKs.

You can also install NetBeans with this command:

sudo apt install netbeans  

JavaFX can run all the JavaFX examples from the "Getting Started with JavaFX" tutorials at the official Oracle website successfully. The only difference from the Oracle tutorials is that in NetBeans openjfx doesn't add a JavaFX Application entry in the File -> New Project -> Java category, so you need to select Java Application instead.

  • I have already installed OracleJDK in my system.It already has javafx right?Moreover , I am able to run the code but the video is not getting played.So I think , I need to install the above libs.. – george Dec 15 '17 at 5:29
  • So ,if that is the case,could u suggest me some way to install the above libs? – george Dec 15 '17 at 5:36
  • You don't ever need to install libavcodec53 or libavformat53 libraries which are both obsolete packages from Ubuntu 12.04 because JavaFX is included in Oracle Java versions 7 and later. I don't know why your video isn't getting played, it depends on the format of the video and the codecs that are required to play it. – karel Dec 15 '17 at 5:41
  • 1
    I have asked a question on this issue here.Could you have a look at it? – george Dec 15 '17 at 5:45
  • Now we're getting somewhere with Java because I can try your code from Stack Overflow. If this answered your question, you can mark this answer as accepted by clicking the gray check mark beside the answer to change its color to green. – karel Dec 15 '17 at 5:46

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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