java.net member

Rechercher dans ce site

Run and Deploy JavaFX applets on Linux Fedora

>> 13 April 2009

Working with JavaFX applets using NetBeans is really straightforward -even- on Linux. The only two things to take care of are :

1.Installation of JavaFX plug-in
2.Installation of Sun's version of Java

Tested configurations :

Fedora 10 64bits
Firefox 3.0.8
NetBeans-6.5.1


Note :
When you launch your applet in Firefox, JavaFX run-time will be downloaded and installed automatically.


Note :
Installing the JavaFX plug-in in NetBeans was detailed in a previous article

http://java-javafx-iipt.blogspot.com/2009/03/javafx-111-netbeans-651-on-linux.html


Use JDK or JRE of Sun Mircosystems

Download the last release of Java as .bin files on Sun's web site

http://java.sun.com

Install .bin file/files if you have not already done this.

Note :
OpenJDK installed by default with Linux distributions has problems running applets

Note :
You can install more than one JDK and JRE on the same machine.

ATTENTION !!!
Do not uninstall or delete OpenJDK, other applications on your system need this.


$ chmod u+x jdk-6u13-linux-i586.bin

$ ./jdk-6u13-linux-i586.bin


Installing Java plug-in in Firefox

$ cd $HOME/.mozilla

Note :
.mozilla is the default Firefox configuration folder of the current user



Go to "plugins" folder
You can create this folder (if not found) in .mozilla


$ cd plugins





Link to libnpjp2.so in .mozilla/plugins

" libnpjp2.so" is the second generation plug-in. You can find it in JDK or JRE installation folder

JDK_install_folder/jre/lib/amd64/libnpjp2.so

Note :
In my example JDK is installed in $HOME ($HOME/jdk1.6.0_13_x86_64)

Note :
If you want to use the plug-in on a 32 bits Linux, replace "amd64" with "i386"


$ ln -s $HOME/jdk1.6.0_13_x86_64/jre/lib/amd64/libnpjp2.so




Create a JavaFX project in NetBeans

The following two links give you an idea about using JavaFX in NetBeans

http://java-javafx-iipt.blogspot.com/2009/02/javafx-dans-netbeans-65-ou-70m1-partie.html



http://java-javafx-iipt.blogspot.com/2009/02/utiliser-javafx-dans-netbeans-partie-2.html

Verify or configure Web Browser in NetBeans

Click on "Tools" -> Options



Edit

"No Proxy" is selected

click on "Edit"



Select Firefox

In Web Browsers -> Firefox

In Process -> Browse to or select your Firefox -> OK



Modify your project configuration to run and deploy applets

Right click on your project in NetBeans -> Properties



Run Options

Select "Run"
Select -> Browser (Configuration)
Select -> "Run in Browser" (Application Execution Model)

Wait ! Do not click on "OK" yet.



Application Options
Modify (if needed) applet's Width and Height -> OK




Clean and Build Project
Every time project's properties are modified -> right click on the project -> Clean and Build Project

Run the Applet
Right click on your project in NetBeans -> Run Project



Firefox is launched it began to download JavaFX run-time



Et voilà the applet is running in Firefox



Note :
If you encounter problems, this might be simply if Firefox is in "Offline" mode. In this case applet will not run.

File -> "Work Offline"




Uncheck " Work Offline "



Reload the page



How to deploy the applet on-line

-Edit projectName_browser.jnlp
In NetBeansProjects/projectName/dist

(my project's name is javafx-images. The file to edit is "/home/kas/NetBeansProjects/javafx-images/dist/ javafx-images_browser.jnlp")

-"codebase" tag must point to a server and a directory on this server

http://www.YourSite.com/AppletsFolder

-Create a folder for the applet on the server

-Copy the following files to the applet's folder (on the server) from NetBeansProjects/dist

NameOfApplication.html
NameOfApplication_browser.jnlp
NameOfApplication.jar

In my Example :

  • javafx-images.html
  • javafx-images.jar
  • javafx-images_browser.jnlp

Run the applet

http://www.YourSite.com/AppletsFolder/NameOfApplication.html

0 comments:

Post a Comment

  © Blogger template Simple n' Sweet by Ourblogtemplates.com 2009

Back to TOP