How to create applet with JNLP support in NetBeans IDE
What will you need?
- Firefox 3
- JDK 6u10 plugin
- NetBeans IDE 6.5 M1 or later
Let's suppose, that you want to develop your own applet, which will benefit from JNLP technology. You are only few steps from having your own applet running if you have both Firefox 3 with the new Java Plug-In and NetBeans 6.5 M1 or later. In the last post, you could have seen, what is the new Java Plug-In Technology capable of. So enough of motivation and let's begin with the tutorial.
Step 1
- open NetBeans IDE 6.5 M1 and create J2SE Project
- select Java category and Java Application project type
- press "next" button

Step 2
- set project name and location
- uncheck Create Main Class checkbox - you'll create JApplet class instead of it later
- press "finish" button - your project is now created

Step 3
- go to main menu and invoke File > New File (or press Ctrl+n)
- select Swing GUI Form Category
- select JApplet Form file type
- press "next" button

Step 4
- set some class name and package name
- press "finish" button

Step 5
- open your JApplet form file and put some components on it to test the applet

Step 6
- now open your project's properties (right click on project's name in projects window and select properties)
- select Web Start category and check enable Web Start
- also check the Self-signed checkbox
- and finally select Applet descriptor radio button
- select your applet class from the combo box
- press "ok" button
- build your project

Step 7
- everything necessary should be now completed
- select Files window
- navigate to dist folder and you'll see (did you really build your project?) two files, whic NetBeans IDE just created for you:
- launch.jnlp - that is your web-startable application, which now contains your applet
- launch.html - simple web page, which includes your applet as JNLP file
- this allows the applet to take benefits of JNLP applications
- just invoke context menu on launch.html and select view - that opens your favorite browser with applet, you have just created

Work completed!
OK, I admit, that Hello World! applet is everything, but amazing or surprising in the year 2008. If you still lack some motivation for applet developing, then just browse to my previous post on this weblog. There are some links to applets, which are everything, but boring.


Thanks for this help....
Posted by Ilie on August 13, 2008 at 01:38 PM CEST #
Thanks for posting this. I am an experienced software jock, but I must say Java is driving me crazy. There are so many aspects to Java it is a bit difficult to know where to start. My main interest is doing 3D science simulations.
Anyway, just a minor correction:
Step 2
set project name and location
uncheck Create Mail Class checkbox - you'll create JApplet class instead of it later
Should be:
uncheck Create Main Class checkbox - you'll create JApplet class instead of it later
Posted by Richard Zipper on December 05, 2008 at 07:08 PM CET #
2 Richard: Thank you, I've corrected the typo.
Posted by Petr Chytil on December 09, 2008 at 11:40 PM CET #
Thanks... :]
Posted by AnarkiFate on January 08, 2009 at 10:56 AM CET #
thanks.
I still cannot start the applet from editor (F11), but at least I can use mouse to build the GUI.
Posted by zeltera on February 17, 2009 at 04:53 PM CET #
Petr - Thank you so much for this help with JNLP. I am trying to learn and this is the first project that actually worked (it did give some warnings about signing and java version but it did run in IE 7 on Win Vista Home using NetBeans 6.5).
PLEASE - add more examples for JNLP. I really need a login page. How can the browser be closed after the application starts so that it runs on the desktop?
Thanks again.
Posted by MilitaryManNavy on March 20, 2009 at 03:02 AM CET #
I have been searching for someone who speaks without the jargon, I am new to java and find as in most walks of life people like to throw everything at you at once.
Thanks for this, nice and simple to follow, however I have 1 question, I already have an application in netbeans that I want to make into an applett, how do I do that?
Thanks again
Posted by Dave on April 17, 2009 at 03:30 AM CEST #
Hi, i Can't get this to run on Ubuntu. I'm using Netbeans 6.5.1, Ubuntu 9.04 with JRE 1.6.0 u13 and Firefox 3.0.10 with the java plugin.
I always get the "APPLET tag missing CODE parameter." error. I guess the browser doesn't get the parameters in the jnlp file or something. Is it the version of java that i'm using? I don't think that it's about the policy.
In windows XP or Vista i can run it just fine.
Is it the java version? is it from firefox? or any package that i need to install that isn't mentioned in the tutorial?
Thanks :)
Posted by Marco on May 09, 2009 at 11:19 PM CEST #
Thank you for your simple guide. If you could just tell me how to run the applet through the appletviewer.
Thanks, in advance.
Posted by giannis on June 15, 2009 at 01:57 AM CEST #
Extremely simple, I was counfounded with why NetBeans wont just let you create an applet from the beggining. Any idea why??
Posted by Christopher Altona on June 25, 2009 at 06:07 PM CEST #
Tks man. This realy helped.
Posted by Dinesh on July 22, 2009 at 12:51 PM CEST #
Hi,from your extremely step by step process help me to create an applet. Thanks for your great support.
Posted by shashikant verma on August 06, 2009 at 09:04 AM CEST #
Excelent. Step by step, great job. I could build my applet instead of using jcreator pro, now I have everything on my netbeans. Thanks
Posted by Nicolas on August 10, 2009 at 03:28 PM CEST #
OMG thanks so much for this tutorial, Im learning JAVA but I didnt had any idea of what applets were, so I had to start reading until I understood, after the real deal was to make an applet in NetBeans, so much that I was thinking on downloading eclipse, but on the last place i fond this tutorial, thx so much again
Posted by Petter on September 07, 2009 at 08:59 PM CEST #
yes, i created an applet as you said. its working. but i want to know, how can i run it from netbeans in ie
Posted by Rose on September 24, 2009 at 07:08 AM CEST #
Hi
I have the same problem like Marco. I always get the "APPLET tag missing CODE parameter." error. I'm using NB 6.7.1, firefox 3.5.5 and JRE 1.6.0_16
Thanks for any help
Posted by tomPD on November 19, 2009 at 09:16 PM CET #