?
Solved

jnlp not working

Posted on 2011-10-13
8
Medium Priority
?
589 Views
Last Modified: 2012-05-12
Hallo,

I am trying a little jnlp project. The java file is attached with this . I am also sending launch.html for your reference





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- ########################## IMPORTANT NOTE ############################ -->
<!-- This preview HTML page will work only with JDK 6 update 10 and higher! -->
<!-- ###################################################################### -->
<html>
    <head>
        <title>Test page for launching the applet via JNLP</title>
    </head>
    <body>
        <h3>Test page for launching the applet via JNLP</h3>
        <script src="http://java.com/js/deployJava.js"></script>
        <script>
            var attributes = {
                code:       "mypackage.MyOwnJApplet",
                archive:    "NextGenApplet.jar",
                width:      300,
                height:     300
            };
            var parameters = {jnlp_href:"launch.jnlp"}; <!-- Applet Parameters -->
            var version = "1.6"; <!-- Required Java Version -->
            deployJava.runApplet(attributes, parameters, version);
        </script>
        <!-- Or use the following applet element to launch the applet using jnlp_href -->
        <!--
        <applet width="300" height="300">
            <param name="jnlp_href" value="launch.jnlp"/>
        </applet>
        -->
    </body>
</html>




I am using Netbeans 7.0.1, Windows 7. When I am right clicking on "launch.html" and select view, only

"Test page for launching the applet via JNLP"

this line is comming in browser. Nothing else. I am expecting a textbox with "Hello World !!!". But it is not comming. Anything wrong in my code?

I have done the following steps also, Project->Properties->Check on Enable Web Start->Check Off Allow Offline->Signing->Self signing by generated key->Applet descriptor->mypackage.MyOwnJApplet

Please help
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MyOwnJApplet.java
 *
 * Created on Oct 13, 2011, 10:55:01 AM
 */
package mypackage;

/**
 *
 * @author SRY_5693
 */
public class MyOwnJApplet extends javax.swing.JApplet {

    /** Initializes the applet MyOwnJApplet */
    public void init() {
        try {
            java.awt.EventQueue.invokeAndWait(new Runnable() {

                public void run() {
                    initComponents();
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /** This method is called from within the init() method to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jTextArea1.setText("Hallo World !!!");
        jScrollPane1.setViewportView(jTextArea1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>                        
    // Variables declaration - do not modify                     
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration                   
}

Open in new window

0
Comment
Question by:Amitava_Mukherjee
  • 5
  • 3
8 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 36966428

Why do you want to launch Applet with JNLP?

Applet is nromally laoded from the server  on the html page and executed
in  the browser when you piint to that page

JNLP is for deploymnt of applications.

If you want the users to start applet - you just provide them
with the address of the HTML page which has applet tag in the page
which pioints to classes on the server.
 
0
 

Author Comment

by:Amitava_Mukherjee
ID: 36966455
for_yan:

thanx for your comment. actually we have some applications as jar file, made by swing or awt. we need to open those from our internal webpage. with some googling i found jnlp is the solution. thats why i am trying to evaluate jnlp and trying to open that from internet explorer
0
 
LVL 47

Accepted Solution

by:
for_yan earned 2000 total points
ID: 36966480
If you wrote your application as an applet extending JApplet class - there is no need to use JNLP which is used for deploying the
Applications (not Applets). When you extend JApplet - these classes are stored on the server and are downloaded ferom the server when the user
points brwoser to the html page which has applet tag.
Then they are executed within briowser (so classes are not written to local drive of the client).

If you write Appliaction (usually extend JFrame), then Java webstart and jnlp file allow the user to access the classes,
and resources obn your server, but only to diownload them and load them lococally oin the client machine
and then in future load an execute them from local machine and run them as, say any local windows applications
with their own windows (not within browser).

As you extened JApplet you don't want to use jnlp.
You want to put soemwhere in the area which is accessible top your web server
the html page which will have the <applet> tag on that page - something like
 <APPLET CODE="Simple.class" archive="classes.jar"
        WIDTH=500 HEIGHT=20>
</APPLET>

Open in new window

and supply the user with the link to this page





           
 
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 47

Expert Comment

by:for_yan
ID: 36966493
In general, you can load applets wiith JNLP, but it is much more common to deploy Applets with Applet tag as I mentioned above
and to use JNLP if you deploy applicatiocations.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36966498
These are the deatils about using the Applet tag:
http://www.iam.ubc.ca/guides/javatut99/applet/appletsonly/html.html
0
 

Author Comment

by:Amitava_Mukherjee
ID: 36966512
for_yan:

thanx for your comment. though it is irrelevant but may i ask you, why jnlp is used?
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 2000 total points
ID: 36966524
Frankly, if you are asking me why it is used for applets - frankly I don't know.
Applets are much more convenient to bring on the web page.

Applications are different - they are usually siginificantly bigger and you want to load them from local drive.
So Java web start  (JNLP) is used as convenient installer of java applications which allows the user to
easily (without direct involevemnt of the user) download the classes from the server deploy them
on local machine and use in fiuture from local machine and also be able to check if the new version
beacme avaialble on the server.
So JNLP is a conveniyent way of delivery of bifg java applications to the uisers.
0
 

Author Closing Comment

by:Amitava_Mukherjee
ID: 36966571
thanx
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This video teaches viewers about errors in exception handling.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question