Friday, April 3, 2009

JavaFX on MacOS.X using Java6 and NetBeans 6.5

I had a problem running JavaFX samples in my Mac OS using Netbeans 6.5 and Java 6. I was getting this build error
init:
deps-clean:
clean:
init:
deps-jar:
Error: JAVA_HOME is not defined, cannot find "java" command.
/Users/puran/NetBeansProjects/Calculator/nbproject/build-impl.xml:143: exec returned: 1
BUILD FAILED (total time: 0 seconds)

Even though i had the environment variable JAVA_HOME defined in my path and java command was working in my console not sure why netbeans was not able to find JAVA_HOME. Also when you install the javafx plugin in Netbeans javafx command is not recognized unless you add it to your PATH variable. Finally i got it working following these steps:

1. Create a .bash_profile file to define few paths, (Note that .bash_profile does not exists by default if you have a new mac so you have to create it manually.)
export JAVA_CMD=$JAVA_HOME/Commands/java
export PATH=$PATH:${JAVA_HOME}/bin:/Users/puran/.netbeans/6.5/javafx-sdk/bin


2.Now go to the location where javafx-sdk is installed by netbeans, in my system it is at location
/Users/puran/.netbeans/6.5/javafx-sdk/bin
Define JAVA_HOME in the script javafx and javafxc files so that it doesn't have to look for JAVA_HOME from some other place.(quite crappy but it works.)


3. Start Netbeans and open sample JavaFx Projects and run it. TA-DA.

No comments :