How to install JavaFx in Ubuntu 12.04?

Solution 1:

Automatically: (via webupd8 helper ppa repository)

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Note: You can replace oracle-java7-installer with oracle-java8-installer or oracle-java9-installer. You will need to accept the Oracle End User License Agreement prior to installation (this isn't required with OpenJDK, so if a OpenJDK back-port is released for 12.04, please update this post! :)

Manually:

  • http://www.wikihow.com/Install-JavaFX-on-Ubuntu-Linux

Solution 2:

You can try setting the CLASSPATH instead of PATH. Java tries to load it's classes from the locations referenced by CLASSPATH.

  • First check your existing classpath with echo $CLASSPATH. Like PATH, the entries for CLASSPATH are separated with :(colon). The presence of a . entry under CLASSPATH means java can always load classes from current directory.
  • To add a .jar library to your CLASSPATH you should open the file ~/.profile and add export CLASSPATH=$CLASSPATH:path to .jar to it. Like in your case it should be

    javaFx_home=/home/anto/javafx/rt/lib/jfxrt.jar
    export CLASSPATH=$CLASSPATH:$javaFx_home

    if . was not present in your previous CLASSPATH entry then modify the last line as
    export CLASSPATH=$CLASSPATH:$javaFx_home:.