JavaFX on linux.

2009 June 26 at 05:01 » Tagged as :netbeans, javafx, wordbuff,

Sun finally woke up and realized that they need to provide a JavaFX platform for linux. And me, someone who has been eagerly looking forward to it, missed the event completely! That was mostly because I jumped from Netbeans 6.5 to Netbeans 6.7 alpha releases and progressed to 6.7 RC2. In the meantime, Netbeans community/Sun quitely released Netbeans 6.5.1 with support for JavaFX and I wasn't monitoring this branch. I stumbled across this only while browsing through the netbeans site. Note to self: you must subscribe to more tech news channels. Not releasing a Linux version at the same time as they released a windows version is a huge blunder. But blundering is what Sun is known for.  It is  the company that goes out of it's way to pretend to be supportive of open source. By forgetting that a huge percentage of people on linux are geeks, they have effectively ensured that there will be a fewer number of applications written for the JavaFX platform than for Air or Silverlight. SilverLight doesn't work on Linux at all (obviously!) and Adobe Air doesn't work on 64 bit linux. Here was a chance to capture an untapped market and sun has largely missed that opportunity. The first and the last time I dabbled with JavaFX was more than six months ago and I didn't get far (was fed up with the lack of support for linux and gave up). So it was time for me to just quickly run through the examples as a refresher, but again I couldn't get far. Netbeans complained:

Trying to override old definition of task nbjavafxconnect Trying to override old definition of task nbjavafxstart Trying to override old definition of task nbjavafxreload Trying to override old definition of task nbjavafxappreloaded init: deps-jar: compile: jar: standard-run: Error: JAVA_HOME is not defined, cannot find "java" command. BUILD FAILED (total time: 3 seconds)

But I do have the JAVA_HOME environment variable defined and no other version of Netbeans has ever complained about it being missing. If you google for this error you will mostly see results from the last decade - that was when people (or java apps) had trouble with environmental variables and classpaths. So instead of going forward sun is going backwards with JavaFX. I solved this problem by editing the /usr/local/netbeans-6.5.1/bin/netbeans script and adding the following at the top:

export JAVA_HOME=/usr/java.6

You will notice that I don't rely on the /etc/alternatives mess. Anyway, once this was done the sample code did run and even the preview which did not show up previously suddenly became active.