Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I download JavaFx from here. I placed it in my home directory(anto) under the name javafx. Then I did something like this :

vi ~/.bashrc

and added the following lines:

export PATH=$PATH:$javaFx_home

But after providing the classpath, I tried running :

groovy MyProgram

(which depends on the JavaFx classpath).

But that throws me an error. Where I went wrong?

share|improve this question

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

    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:.
share|improve this answer

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! :)


share|improve this answer
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Eliah Kagan Jul 5 '12 at 12:59

Here is what I've found so far.

I downloaded JavaFX SDK 1.2 and 2.2. They have removed some files from JavaFX SDK.

For 1.2

virpara@Ascension:~$ tree -L 2 '/home/virpara/Desktop/javafx-sdk1.2' 
|-- bin
|   |-- javafx
|   |-- javafxc
|   |-- javafxdoc
|   `-- javafxpackager
|-- COPYRIGHT.html
|-- docs
|   |-- api
|   |-- emulator.html
|   |-- index.html
|   |-- javafxc.html
|   |-- javafxdoc.html
|   |-- javafx.html
|   |-- javafxpackager.html
|   `-- manpage.css
|-- emulator
|   `-- bin
|-- lib
|   |-- desktop
|   |--
|   |-- mobile
|   `-- shared
|-- LICENSE.txt
|-- profiles
|   |--
|   `--
|-- README.html
|-- samples
|   |-- DisplayShelf
|   |-- DisplayShelfMobile
|   |-- DragAndDrop
|   |-- index.html
|   |-- InterestingPhotos
|   |-- LocalSearch
|   |-- MediaBox
|   |-- PathAnimation
|   |-- PhotoEffects
|   |-- PhotoFlip
|   |-- shared
|   `-- SpringAnimation
|-- servicetag
|   `-- registration.jar
`-- timestamp

23 directories, 23 files

For 2.2

virpara@Ascension:~$ tree -L 2 '/home/virpara/Desktop/javafx-sdk2.2.0-beta' 
|-- bin
|   `-- javafxpackager
|-- COPYRIGHT.html
|-- docs
|   `-- api
|-- lib
|   |-- ant-javafx.jar
|   |-- javafx-doclet.jar
|   `-- javafx-mx.jar
|-- README.html
|-- rt
|   |-- COPYRIGHT.html
|   |-- lib
|   |-- README.html

6 directories, 10 files

There is only javafxpackager script in javafx-sdk2.2.0-beta/bin (javafx, javafxc, javafxdoc scripts are removed) it means that if you export javafx-sdk2.2.0-beta/bin to your PATH variable and try to execute javafx --version in terminal it can't find javafx because there is no executable named javafx.

Well I've no experience with JavaFX but probably they have removed other three scripts because it would not be needed and perhaps javafxpackager would do the thing or java is enough for that.

You've tried to include whole path to jfxrt.jar to PATH variable.

it won't work because it can't automatically pass to -cp parameter. So, you must give full path to jfxrt.jar as -cp /anto/javafx/rt/lib/jfxrt.jar

java -cp /anto/javafx/rt/lib/jfxrt.jar

I know it is not a solution.

share|improve this answer

I have the same problem, and @samik answer works for me !

Into my ~.bashrc , like @samik say :

export JAVAFX_HOME=/usr/lib/jvm/javafx-sdk2.2.0-beta/rt/lib/jfxrt.jar

Now a little source .profile and we try with an example


I cut/copy this example code into the file :

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.*;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;

 * Simple demonstration of JavaFX text support.
 * @author Dustin
public class JavaFxText extends Application
    * Start demonstration of JavaFX text capabilities.
    * @param stage Stage for JavaFX application.
    * @throws Exception Exception in JavaFX application.
   public void start(final Stage stage) throws Exception
      stage.setTitle("Simplistic Example of JavaFX 2.0 Text Capabilities");
      final Group rootGroup = new Group();
      final Scene scene =
         new Scene(rootGroup, 800, 400, Color.BEIGE);

      final Text text1 = new Text(25, 25, "(2007) JavaFX based on F3");
      text1.setFont(Font.font(java.awt.Font.SERIF, 25));

      final Text text2 = new Text(25, 50, "(2010) JavaFX Script Deprecated");
      text2.setFont(Font.font(java.awt.Font.SANS_SERIF, 30));

      final Text text3 = new Text(25, 75, "(2011) JavaFX to be Open Sourced!");
      text3.setFont(Font.font(java.awt.Font.MONOSPACED, 35));

      final Text text4 = new Text(25, 125, "(2011) JavaFX to be Standardized");
      text4.setFont(Font.font(java.awt.Font.DIALOG, 40));
      final Effect glow = new Glow(1.0);

      final Text text5 = new Text(25, 175, "(Now) Time for JavaFX 2.0!");
      text5.setFont(Font.font(java.awt.Font.SERIF, FontWeight.EXTRA_BOLD, 45));
      final Light.Distant light = new Light.Distant();
      final Lighting lighting = new Lighting();

      final Text text6 = new Text(25, 225, "JavaFX News at JavaOne!");
      text6.setFont(Font.font(java.awt.Font.DIALOG_INPUT, FontWeight.THIN, 45));
      final Reflection reflection = new Reflection();


    * Main JavaFX application launching method.
    * @param arguments Command-line arguments: none expected.
   public static void main(final String[] arguments)

And it's running

java JavaFxText

Give the bounty to @samik, he deserves !!

share|improve this answer

please go on considering line by line..

  1. Download the JavaFX SDK shell script for Linux. The JavaFX SDK shell script in most cases will probably be downloaded to: /home/"your_user_directory"/Downloads

  2. Change into the root user by performing the following actions:

  3. Type/Copy/Paste: sudo -s

  4. Type/Copy/Paste: cd /home/"your_user_directory"/Downloads

  5. Type/Copy/Paste: cp -r /usr/local

  6. Type/Copy/Paste: cd /usr/local

  7. And as root, make the JavaFX shell script executable by running the following commands:

  8. Type/Copy/Paste: sudo chmod a+x

  9. Then execute the shell script by running either:

Type/Copy/Paste: sudo ./ or Type/Copy/Paste: sudo sh

  1. Edit the Ubuntu Linux system path variable in /etc/profile, use a text editor as root such as nano or gedit. Type/Copy/Paste: sudo nano /etc/profile or Type/Copy/Paste: sudo gedit /etc/profile

  2. Add the following lines below to your /etc/profile system wide path: PATH=$PATH:$JAVAFX_HOME:/usr/local/javafx-sdk1.3/bin export JAVAFX_HOME export PATH

  3. Save the file and exit

  4. Reload your /etc/profile file by running the following command: Type/Copy/Paste: . /etc/profile

  5. Open a terminal in Ubuntu Linux issue the following command: Type/Copy/Paste: javafx -version

This command let's you know which version of javafx is installed on your system You should receive a message similar to: javafx 1.3.1_b101

  1. Also run the following command: Type/Copy/Paste: javafxc -version This command will allow you to compile javafx programs from the terminal You should receive a message which states: javafxc 1.3.1_b101

  2. Now reboot your Ubuntu Linux system and JavaFX should be fully installed for use.

share|improve this answer
Well I need a way to install JavaFx 2.0 – Ant's Jun 4 '12 at 6:02
i already gave it to may follow it... – Rajat Jun 4 '12 at 6:18
I meant to say that there is no shell script available for JavaFx 2.0 – Ant's Jun 4 '12 at 6:23
The bin subdirectory contains the javafxpackager, a shell script internally documented as being the "JavaFX Packager tool execution script for Linux/Solaris/OS X. – Rajat Jun 5 '12 at 4:22
@metauser it won't work with JavaFx 2.0.X – virpara Jun 8 '12 at 15:49

protected by Community Jun 12 '12 at 19:20

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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