Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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:

javaFx_home=/anto/javafx/rt/lib/jfxrt.jar
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

5 Answers 5

Read this >> http://www.wikihow.com/Install-JavaFX-on-Ubuntu-Linux

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

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

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' 
/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
|-- invoice.properties
|-- lib
|   |-- desktop
|   |-- javafx-runtime.properties
|   |-- mobile
|   `-- shared
|-- LICENSE.txt
|-- profiles
|   |-- desktop.properties
|   `-- mobile.properties
|-- README.html
|-- samples
|   |-- DisplayShelf
|   |-- DisplayShelfMobile
|   |-- DragAndDrop
|   |-- index.html
|   |-- InterestingPhotos
|   |-- LocalSearch
|   |-- MediaBox
|   |-- PathAnimation
|   |-- PhotoEffects
|   |-- PhotoFlip
|   |-- shared
|   `-- SpringAnimation
|-- servicetag
|   `-- registration.jar
|-- src.zip
|-- THIRDPARTYLICENSEREADME.txt
`-- timestamp

23 directories, 23 files

For 2.2

virpara@Ascension:~$ tree -L 2 '/home/virpara/Desktop/javafx-sdk2.2.0-beta' 
/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
|   `-- THIRDPARTYLICENSEREADME.txt
`-- THIRDPARTYLICENSEREADME.txt

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 MyProgram.java

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
export CLASSPATH=$CLASSPATH:$JAVAFX_HOME:.

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

touch JavaFxText.java

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.
    */
   @Override
   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.setFill(Color.CHOCOLATE);
      text1.setFont(Font.font(java.awt.Font.SERIF, 25));
      rootGroup.getChildren().add(text1);

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

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

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

      final Text text5 = new Text(25, 175, "(Now) Time for JavaFX 2.0!");
      text5.setFill(Color.DARKVIOLET);
      text5.setFont(Font.font(java.awt.Font.SERIF, FontWeight.EXTRA_BOLD, 45));
      final Light.Distant light = new Light.Distant();
      light.setAzimuth(-135.0);
      final Lighting lighting = new Lighting();
      lighting.setLight(light);
      lighting.setSurfaceScale(9.0);
      text5.setEffect(lighting);
      rootGroup.getChildren().add(text5);

      final Text text6 = new Text(25, 225, "JavaFX News at JavaOne!");
      text6.setFill(Color.DARKGREEN);
      text6.setBlendMode(BlendMode.COLOR_BURN);
      text6.setFont(Font.font(java.awt.Font.DIALOG_INPUT, FontWeight.THIN, 45));
      final Reflection reflection = new Reflection();
      reflection.setFraction(1.0);
      text6.setEffect(reflection);
      rootGroup.getChildren().add(text6);

      stage.setScene(scene);
      stage.show();
   }

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

And it's running

javac JavaFxText.java
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 javafx_sdk-1_3-linux-i586.sh /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 javafx_sdk-1_3-linux-i586.sh

  9. Then execute the shell script by running either:

Type/Copy/Paste: sudo ./javafx_sdk-1_3-linux-i586.sh or Type/Copy/Paste: sudo sh javafx_sdk-1_3-linux-i586.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 you...you 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 answers, posting an answer now requires 10 reputation on this site.

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.