Dynamic generation of jnlp file

I'm dynamically generating a jnlp file using a jsp to pass run-time parameters over to my Java application thusly:
<%
response.setContentType("application/x-java-jnlp-file");
String userName = request.getParameter("username");
String password = request.getParameter("password");
String batchId = request.getParameter("batchid");
out.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
out.println("<jnlp ");
out.println("spec=\"1.0+\" ");
out.println("codebase=\"http://server/directory\" ");
out.println("href=\"this jsp file\">");
... other jnlp stuff...
out.println("<application-desc main-class=\"myApp.myClass\">");
out.println("<argument>" + userName + "</argument>");
out.println("<argument>" + password + "</argument>");
out.println("<argument>" + batchId + "</argument>");
out.println("</application-desc>");
out.println("</jnlp>");
And use args[] to attempt to get the passed parameters in the Java application:
userName = args[0];
password = args[1];
batchId = args[2];
However, they don't seem to be passed over to the application as I get NullPointerExceptions. If I try to trace the state of the arguments by adding:
FileOutputStream f = new FileOutputStream("w:output.txt");
BufferedWriter w = new BufferedWriter(new OutputStreamWriter(f, System.getProperty("file.encoding")));
w.write("userName: " + userName);
w.write("password: " + password);
w.write("batchId: " + batchId);
f.flush();
f.close();
The output file is completely empty.
1. Am I passing the arguments in wrongly?
2. Why is the output not being written in the file?
My thanks in advance for any assistance offered.
Erkton

Erkton,
I use a similar approach and it does work. The main gotchas I found were typos. I would suggest temporarily changing the
response.setContentType("application/x-java-jnlp-file");
line to
response.setContentType("text/xml");
and looking at your JNLP file as XML and verifything that you got everything write. Look for beginning and end tags, stuff like that.
Once you have it right then switch it back to JNLP.
One other thing to look out for is Internet Explorer doesn't like jnlp files unless they end with a .jnlp extension. I had to rename my jnlp files to end with .jnlp instead of .jsp for IE to parse them correctly. I don't think thats the issue you are running into, but you may want to look out for it.

Similar Messages

  • Dynamically generating the jnlp file

    Hi Experts,
    Im working on a project in which we launch the Eclipse RCP from the web UI (thin client).
    I want to dynamically generate the jnlp file cause I want to pass the session of the user from the web client to RCP.
    So for this i have thought of having a variable let say sessionID ,which will take value of the session
    sum thing like this...
    <application-desc main-class="com.rcp.core.HelloWorld">
    <property name="sessionID" value="$$userSessionId"/>
    </application-desc>
    But im not able to figure out how i will populate the sessionID variable.
    which class should be responsible for doing this?
    whether that class will be in the RCP code or in the Web code...i guess it is in the web code?
    Please if u can clarify these doubts then it will be great.
    Thanks
    ved

    usually you would use jsp or a servlet to generate the jnlp file.
    If you extend the JnlpDownloadServlet (found in the sample directory in the JDK) you can generate the session id.
    /Andy

  • Download .jnlp file when first time

    Hi Everybody,
    I am new bee for java web start.
    We are having swing application which we want to distribute through Java Web Start. Client can run application through provided web link. we also want to download .jnlp file to the client machine when user clicked the link first time.
    I go through different thread for the above problem in this forum, but though not getting clear idea as in our application, we need to generate dynamic .jnlp file. All solution posted for the above problem assuming that .jnlp file exists at some location, but in our case we have to generate it when user clicked it first time. Any body having some idea ?
    Our second problem is, can it possible that user will run the swing application only when he click the link provided on the web server ? In our case authentication of user is done in our web application and when user will click the provided link user id and other information will be pass to swing application as parameters through .jnlp file. If that application will available offline user can run it through last downloaded .jnlp file without clicking the link , which will be not allowded. Also we are concern about multi user environment, as we are thinking to dynamic generation of .jnlp file , it may possible that other user running the same application noted .jnlp file version difference and will download the .jnlp file of other user ?
    Can any body have any idea, how can we done the above scenario ?
    Thanks in advance,
    Dimpal

    If you upgrade to Java 1.4.2 it will present a dialog asking for desktop
    integration the first time you start the application.
    Maybe that's what you want?

  • Jnlpdownloadservlet and dynamic jnlp file

    Problem: we want the version handling (+ jardiff) of JnlpDownLoadServlet, but we also need to construct the jnlp file dynamically (for example: a .jsp file). It seems to me there are two solutions, neither of them good: a) hack the JnlpDownloadServlet (or roll our own), intercepting the jnlp-file-reading code to forward to the jsp page that generates the jnlp xml data and use the generated response as the file contents.
    b) generate each jnlp file dynamically and then store it in a temporary location for the JnlpDownloadServlet to pick up. This entails aging the temporary jnlp files and deleting them so the server doesn't get clogged with dead jnlp files.
    Is there a third possibility? Or something in the pipe for the near future?
    (Note: Web Start Services is not a solution for this task since WSS doesn't support jar versioning, and since the $$properties mechanism does not appear to be ideal for passing a lot of dynamic jnlp information.)
    Thanks in advance for any advice.

    My jsp page actually generates the list of jars for the application. It also passes some info specific to the user session by means of the jnlp file. Since we are doing games, the list of applications keeps growing. By generating the resource elements dynamically for a game, we can reduce maintenance (as opposed to having a large number of jnlp files with mostly duplicate code) -- especially when a version is updated.
    Till we can move to 1.5, I plan to use the temporary file creation method.
    Thanks, --John                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Dynamic JNLP files?

    I have a number of small, embedded devices running a Cherokee web server, each with their own IP address and hostname. Each of these devices has a standard image that includes a few applets. Is there a way to make a standard JNLP file that could go in the image but would still work? My concern is that the codebase is going to be different for device...

    A way to generate dynamic JNLP's is by using a servlet.
    The servlet path is the JNLP target for the client, and the servlet itself outputs the JNLP contents with the JNLP content-type.
    Jacco

  • Always prompted to save JNLP file

    Hello! We have a simple servlet that basically just queries a few things off of the HttpServletRequest and spits back a dynamically generated JNLP file. For some reason, when we were running with Tomcat 4.0.6 this worked fine, but with the upgrade to Tomcat 4.1.29 it does not. IE always prompts to open or save the file - it never just launches JWS automatically anymore.
    Any suggestions on what we can fix? I'll put the interesting parts of the servlet below.
    Thanks in advance!
    -Angelina
    Servlet:
    public class JNLPServlet extends HttpServlet{
        public void doGet(HttpServletRequest request, HttpServletResponse response)
           throws IOException, ServletException {
            try {          
                response.setHeader("Cache-Control", "public");
                response.setContentType("application/x-java-jnlp-file");
                String sessionId = getSessionId(request);
                ServletOutputStream out = response.getOutputStream();
                java.net.InetAddress[] hostNetAddrs =
                              java.net.InetAddress.getAllByName(request.getServerName());
                String hostIpAddr = hostNetAddrs[0].getHostAddress();
                out.println(generateJNLP(sessionId, request.getServerName(),
                                         hostIpAddr, request.getRemoteUser()));
                out.flush();          
            catch (IOException ex) {
                response.sendError(javax.servlet.http.HttpServletResponse.
                                   SC_SERVICE_UNAVAILABLE, ex.getMessage());
            catch (Exception ex) {
                response.sendError(javax.servlet.http.HttpServletResponse.
                                   SC_INTERNAL_SERVER_ERROR, ex.getMessage());
        protected String generateJNLP(String sessionId, String host, String ip, String userName){
            StringBuffer buf = new StringBuffer();
            buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
            buf.append("<jnlp spec=\"1.0+\" codebase=\"http://" + ip + ":80/cmv2/\">\n");
            buf.append("<information>\n");
            buf.append("<title>App V2.3 on " + host + "</title>\n");
            buf.append("<vendor>EMC Corporation</vendor>\n");
            buf.append("<homepage href=\"http://www.emc.com\" />\n");
            buf.append("<description>Program for monitoring performance.");
            buf.append("</description>\n");
            buf.append("<icon href=\"cm.gif\" width=\"32\" height=\"32\" depth=\"3\" size=\"1k\" />\n");
            buf.append("<offline-allowed />\n");
            buf.append("</information>\n");
            buf.append("<security>\n");
            buf.append("<all-permissions />\n");
            buf.append("</security>\n");
            buf.append("<resources>\n");
            buf.append("<j2se version=\"1.4+\" href=\"http://java.sun.com/products/autodl/j2se\"");
            buf.append("initial-heap-size=\"64m\" max-heap-size=\"194m\" />\n");
            buf.append("<property name=\"host_name\" value=\"" + host + "\"/>\n");
            buf.append("<property name=\"host_port\" value=\"80\"/>\n");
            buf.append("<property name=\"host_IP\" value=\"" + ip + "\"/>\n");
            buf.append("<property name=\"secure_host_port\" value=\"443\"/>\n");
            buf.append("<property name=\"session_id\" value=\"" + sessionId + "\"/>\n");
            buf.append("<property name=\"user_name\" value=\"" + userName + "\"/>\n");
            buf.append("<jar href=\"cmv2.jar\" />\n");
            buf.append("<jar href=\"ohj-jewt-4_1_9.jar\" />\n");
            buf.append("<jar href=\"help-4_1_9.jar\" />\n");
            buf.append("<jar href=\"oracle_ice-5_06_3.jar\" />\n");
            buf.append("<jar href=\"emcshared.jar\" />\n");
            buf.append("<jar href=\"xerces.jar\" />\n");
            buf.append("</resources>\n");
            buf.append("<application-desc main-class=\"com.emc.wclient.Login\">\n");
            buf.append("</application-desc>\n");
            buf.append("</jnlp>\n");
            return buf.toString();
    }

    The underlying problem is a combination of tomcat 4/5 being more standard and IE being less standard. Tomcat changed to automatically add ";charset=ISO-8859-1" to the end of the Content-Type header while IE appears to not correctly process the Content-Type header.
    IE maintains a list of known MIME types in the registry under [HKCR]\MIME\Database\Content Type. There you will find an entry for 'application/x-java-jnlp-file' which indicates that this MIME type is treated as a file with the suffix '.jnlp'.
    Unfortunately, IE treats EVERYTHING after the Content-Type: as the MIME type NOT just the stuff between the ':' and the ';'. Thus instead of looking for a registry entry for 'application/x-java-jnlp-file' it winds up looking for 'application/x-java-jnlp-file;charset=ISO-8859-1" and doesn't find it.
    If you duplicate the 'application/x-java-jnlp-file' entry with the name 'application/x-java-jnlp-file;charset=ISO-8859-1' everything works. Alternatively, if you make sure the 'file name' portion of the URL which requests the jnlp spec has the suffix '.jnlp' IE will work correctly. If you are generating the jnlp spec via your own servlet you can control the behavior of Tomcat by calling 'setCharacterEncoding(null)' on the response object (note this is not a method of the HttpServletResponse interface, you have to cast to the underlying concrete type).
    So, I think IE's use of the 'suffix' is non-standard and IE's handling of the Content-Type header field is just broken. If you can make the requesting URL have the .jnlp suffix you are ok; otherwise, there does not appear to be a good solution.

  • Console does not launch OVM 3.1.1, Win7x32 Firefox15/IE8 - Empty .jnlp file

    I have installed Oracle VM Manager 3.1.1, and two Oracle VMS servers; all seems to have gone pretty well after some learning curve. After success here, I created Clone of the most recent PeopleTools 8.5.2 and PeopleSoft HCM templates, and was able to start those machines. (Or at least, the Virtual Machine status shows "Running..." - read on.)
    However, when I try to launch the console, I get no success. First, when accessing the VMM server over HTTPS (port 7002), Java doesn't even try to start. Instead, basically, I get a screen blink and nothing else when I try to Launch Console from HTTPS. But when using HTTP:myVMM:7001, I get further. The Java logo appears briefly, and then I get "Application Error - Unable to launch the application" dialog. When I click on Details, I see the following under the Exception tab:
    JNLParseException[ Could not parse launch file. Error at line 0.]
         at com.sun.javaws.jnl.XMLFormat.decode(Unknown Source)
         at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
         at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
         at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
         at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
         at com.sun.javaws.Main.launchApp(Unknown Source)
         at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
         at com.sun.javaws.Main$1.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Looking further into this, the .jnlp that's presented to JAVA by Launch Console is zero bytes in length. What might cause the .jnlp file to be empty?

    Thank you very much for your rapid reply, SPA2! It's encouraging!
    You named the file correctly, and there is only one ovm_rasproxy-ws.jnlp on the system. It is at /u01/app/oracle/ovm-manager-3/machine1/base_adf_domain/servers/AdminServer/tmp/_WL_user/ovm_core/tgzc2b/war/ovm_rasproxy-ws.jnlp. It is not empty - has a size of 1028 bytes, and the contents are listed at the bottom of this message.
    I don't know how to start the vncviewer directly from the OVM Manager machine. I did install the package (twice, in fact... and the second time stated "package tightvnc-java-1.3.9-3.noarch is already installed" There are no executables in the tightvnc-java-1.3.9-3.noarch.rpm package, and I have not found indication of what the URL would be. Can you help with that?
    Trying to find the version of Java from http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&ved=0CCwQFjAB&url=http%3A%2F%2Fwww.java.com%2Fen%2Fdownload%2Finstalled.jsp&ei=cFyOUL6OHpHo8QSrn4GIBg&usg=AFQjCNH6zuZGOL1prgUuefMNfg4eSpEOjQ I see "Something is wrong. Java is not working." So I uninstalled and reinstalled Java. Now it is Java 7 Update 9.
    Also - to further check this out, I did Save instead of Open from Firefox (IE does not give that option). Firefox saved a 0 byte file. I really appreciate the help.
    Contents of ovm_rasproxy-ws.jnlp:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="${Scheme}://${Server}:${ServerPort}/ovm/rasproxy/"
    href="ovm_rasproxy-ws.jnlp?${RequestUri}">
    <information>
    <title>Oracle VM Remote Access Service</title>
    <vendor>Oracle</vendor>
    <homepage>http://support.oracle.com/</homepage>
    </information>
    <resources>
    <!-- Application Resources -->
    <j2se version="1.5+"
    href="http://java.sun.com/products/autodl/j2se" />
    <jar href="ovm_rasproxy-signed.jar" main="true" />
    <jar href="commons-logging-1.1.1.jar" />
    </resources>
    <application-desc main-class="com.oracle.ovm.ras.proxy.RasProxyApplet">
    <argument>-server</argument>
    <argument>${Server}</argument>
    <argument>-service</argument>
    <argument>${Serviceid}</argument> <!--dynamic-->
    ${Credentials}
    </application-desc>
    <security>
    <all-permissions/>
    </security>
    <update check="always"/>
    </jnlp>
    Edited by: Dennis Lovelady on Oct 29, 2012 3:32 AM
    Edited by: Dennis Lovelady on Oct 29, 2012 3:36 AM to answer about installation of tightvnc and about Java version
    Edited by: Dennis Lovelady on Oct 29, 2012 4:10 AM

  • How to change the argument input in a jnlp file?

    A question associated with the following few lines of jnlp codes:
    <application-desc main-class="Main">
    <argument>arg</argument>
    </application-desc>
    My question is: "How can 'arg' be changed dynamically?
    Thanks for help.

    Thank Dietz for help.
    I tried the following jsp code. But it can launch the application only when "test2.jnlp" file exists. "argument to change" can't be passed to the application.
    Thanks.
    <% response.setContentType("application/x-java-jnlp-file");
    out.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
    out.println("<jnlp ");
    out.println("spec=\"1.0+\" ");
    out.println("codebase=\"http://tang:8080/examples/rtla/\"");
    out.println("href=\"test2.jnlp\">");
    out.println("<information> ");
    out.println("<title>RTLAFrame viewer</title> ");
    out.println("<vendor>XXX, Inc.</vendor> ");
    out.println("<description>RTLAviewer Application Demo</description>");
    out.println("<description kind=\"short\">A viewer.</description> ");
    out.println("<offline-allowed/> ");
    out.println("</information> ");
    out.println("<security> ");
    out.println("<all-permissions/>");
    out.println("</security> ");
    out.println("<resources> ");
    out.println("<j2se version=\"1.3+\"/>");
    out.println("<jar href=\"test.jar\"/> ");
    out.println("</resources> ");
    out.println("<application-desc main-class=\"RTLAFrame\">");
    out.println("<argument>argument to change</argument>");
    out.println("</application-desc> ");
    out.println("</jnlp> ");
    %>

  • How to pass a dynamic value to jrxml file???

    Hi all,
    let me know a thing,How to pass a dynamic id value to the query in jrxml file.
    <queryString>
    <![CDATA[select currency_id from currency]]>
    </queryString>
    Because for every user,we have to generate a jasper report based on their loginId.So we have to maintain a dynamic value in jrxml file inorder to get records from table.
    <queryString>
    <![CDATA[select currency_id from currency where cid="DynamicId value"]]>
    </queryString>
    is the above mentioned tag possible???If it so kindly let me know how to do this from jsp page to jrxml file(Assume that jsp page calls jrxml file for report generation).
    Thanks in advance,
    sundar,

    hi all
    i m dealing wid same problem
    i used abv code bt some problem is still there
    foll is the code:
    code]
    Enumeration e=request.getParameterNames();
    while(e.hasMoreElements()){
    out.println("fgdgf");
    String name=(String)e.nextElement();
    String value=request.getParameter(name);
    stmt = dbconn.prepareStatement("UPDATE applicants SET statusLocal = 'n' where empNo = '" +value+ "'"); 
    int rowsAffected=stmt.executeUpdate();
    out.println(stmt);
    if(rowsAffected!=0){
    out.println("Successfull");
    else {
    out.println("Failed");
    }           while condition is not satisfied
    control does not enter the while loop
    can u plz tel me wht shud b the problem..
    thnx

  • Dynamic generation of .cex for window classes

    subject :dynamic generation of .cex for window classes:
    Hi,
    I want to generate windows classes (cex export file) with tool
    code. I don't have any problem with non windows attributes.
    But I can't generate windows attributes: the export file contains a
    serialized object but I don't know which object.
    thank you for your help.
    Corinne
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    value="Button_#{myBean.id}"This is perfectly valid syntax.
    But you're talking about "dynamic generation of IDs". Don't you instead mean something like:
    id="Button_#{myBean.id}"?
    If so, then yes, using EL in the ID attribute is prohibited. Also see the TLDDOC [1]. Why do you want to do it anyway? The f:attribute might be more useful for you [2].
    [1] http://java.sun.com/javaee/javaserverfaces/1.2/docs/tlddocs/
    [2] http://balusc.blogspot.com/2006/06/communication-in-jsf.html

  • Passing arguments from jnlp file to application

    Hi,
    I am using a jnlp file to launch an application. This is working perfectly. Now I want my application to get some custom properties for making an rmi connection . The only place where I must specify this is in the jnlp file which is dynamically generated. The dynamically generated JNLP file contains:
    <property name="abc.rmi.adapter.host" value="localhost"/>
    <property name="abc.rmi.adapter.port" value="5050"/>
    <property name="abc.rmi.adapter.servicename" value="abc/RMIClientAdapter/"/>
    This does not work.
    However, according to sun only certain types of properties are supported by jnlp for security reason. Is there any way to get over this and have my custom properties. Any help will be appreciated.
    Thanks,
    dasappan

    If you are trying to use RMI, you probably need all-permissions allready.
    for applications requesting all-permissions, all of the properties set in the jnlp file will be set as system properties before the applications "main" is called.
    If you are not using <security><all-permissions/></security>, then only specific trusted properties, plus any begining with "javaws." or "jnlp." will be allowed.
    For properties you just need to pass to yourself, just append "jnlp." to the front of them.
    /Andy

  • JNLP file caching

    I have a JNLP file that does not include <offline-allowed/>. How long does JWS cache such a JNLP file?
    The reason I ask is that I had a bug (my fault) with which the JNLP file didn't correctly reference itself---it referenced a non-existent JNLP file. JWS gave me an error, but the JNLP file it listed in the error report was a different JNLP file altogether---one that I was working on earlier, and that didn't even exist anymore!
    How can I make sure the JNLP file is never cached? Do I have to send all sorts of headers to turn of the cache, such as Pragma: no-cache and the like?
    Garret

    Ooh, this is really bad.
    JWS apparently caches the JNLP uses it for any remote JNLP accessed at the same remote URL ignoring any URL query parameters!.
    I have a JNLP that is dynamically generated at example.com/jnlp?param=value
    Once I've downloaded the application, JWS tucks it away and uses it forever and ever!
    If later I try to access a different JNLP at example.com/jnlp?param=anothervalue, JWS completely ignores the contents of the actual JNLP it gets from the web and uses its locally cached version, which of course has a different href than the one that was generated from example.com/jnlp?param=anothervalue. JWS then tries to go get the JNLP from the wrong href, either retrieving a different JNLP or giving an error.
    What can I put in my JNLP to tell JWS not to cache it? Why doesn't JWS look at the whole URL, or look at times and dates, or something rather than just blindly caching my JNLP?
    Garret

  • Trying to call a Java3D application from .jnlp file

    Hi everybody,
    I'm trying to execute a java3D simple program making use of a *.jnlp* file, but isn't working...
    Can anybody help? Thanks in advance.
    This is what I have:
    simple.jnlp
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+"
    codebase="file:///the_path/jnlp/">
    <information>
      <title>Hello JNLP</title>
      <homepage href="http://whatever.com" />
      <vendor>My self </vendor>
      <offline/>
    </information>
    <resources>
      <j2se version="1.2+" />
      <jar href="bin/HelloJava3Da.jar" />
      <jar href="bin/j3dcore.jar" />
      <jar href="bin/j3dutils.jar" />
      <jar href="bin/vecmath.jar" />
    </resources>
    <application-desc main-class="HelloJava3Da" />
    </jnlp>First, I had to generate the HelloJava3Da.jar, which contains HelloJava3Da.class (my program compiled and working when using java command).
    Generation of HelloJava3Da.jar :
    $ jar cf HelloJava3Da.jar HelloJava3Da.class
    $ jarsigner -keystore myKeys HelloJava3Da.jar jdcFinally, when I try to run simple.jnlp, making use of Firefox:
    firefox simple.jnlpThe result is:
    Error: Unexpected exception: java.lang.reflect.InvocationTargetException
    java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.javaws.Launcher.executeApplication(Launcher.java:1272)
         at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1218)
         at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1065)
         at com.sun.javaws.Launcher.run(Launcher.java:105)
         at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.ExceptionInInitializerError
         at javax.media.j3d.VirtualUniverse.<clinit>(VirtualUniverse.java:227)
         at HelloJava3Da.<init>(HelloJava3Da.java:23)
         at HelloJava3Da.main(HelloJava3Da.java:53)
         ... 9 more
    Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)
         at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
         at java.security.AccessController.checkPermission(AccessController.java:546)
         at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
         at java.lang.SecurityManager.checkAccess(SecurityManager.java:712)
         at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:288)
         at java.lang.ThreadGroup.getParent(ThreadGroup.java:139)
         at javax.media.j3d.MasterControl$16.run(MasterControl.java:3680)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.media.j3d.MasterControl.<clinit>(MasterControl.java:3673)
         ... 12 moreI have already made the same procedure with a none Java3D program (*TheTime.class*) and everything run well... With my java3D program is not...
    TheTime.java
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    import java.net.*;
    public class TheTime {
      public static void main(String args[]) {
        JFrame frame =  new JFrame("Time Check");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JLabel label = new JLabel();
        Container content = frame.getContentPane(); 
        content.add(label, BorderLayout.CENTER);
        String message = "missing";
        BufferedReader reader = null;
        try {
          Socket socket = new Socket("time.nist.gov", 13);
          InputStream is = socket.getInputStream();
          InputStreamReader isr = new InputStreamReader(is);
          reader = new BufferedReader(isr);
          reader.readLine(); // skip blank line
          message = reader.readLine();
        } catch (MalformedURLException e) {
          System.err.println("Malformed: " + e);
        } catch (IOException e) {
          System.err.println("I/O Exception: " + e);
        } finally {
          if (reader != null) {
            try {
              reader.close();
            } catch (IOException ignored) {
        label.setText(message);
        frame.pack();
        frame.show();
    HelloJava3Da.java
    import java.applet.Applet;
    import java.awt.BorderLayout;
    import java.awt.Frame;
    import java.awt.event.*;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.ColorCube;
    import javax.media.j3d.BranchGroup;
    import javax.media.j3d.Canvas3D;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import java.awt.GraphicsConfiguration;
    //import com.sun.j3d.utils.universe.SimpleUniverse;
    //   HelloJava3Da renders a single, rotating cube.
    public class HelloJava3Da extends Applet {
      public HelloJava3Da() {
       setLayout(new BorderLayout());
       GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
       Canvas3D canvas3D = new Canvas3D(config);
       add("Center", canvas3D);
       BranchGroup scene = createSceneGraph();
       // SimpleUniverse is a Convenience Utility class
       SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
       // This will move the ViewPlatform back a bit so the
       // objects in the scene can be viewed.
       simpleU.getViewingPlatform().setNominalViewingTransform();
       simpleU.addBranchGraph(scene);
    } // end of HelloJava3Da (constructor)
      public BranchGroup createSceneGraph() {
        // Create the root of the branch graph
        BranchGroup objRoot = new BranchGroup();
        objRoot.addChild(new ColorCube(0.4));
        return objRoot;
    } // end of CreateSceneGraph method of HelloJava3Da
    //  The following allows this to be run as an application
    //  as well as an applet
    public static void main(String[] args) {
       Frame frame = new MainFrame(new HelloJava3Da(), 256, 256);
    } // end of main (method of HelloJava3Da)
    } // end of class HelloJava3Da

    I have a collection of Java3d applets launched with Java3d:
    http://astral.mobile-visuals.com/3d_visuals.php
    You can compare your code for the page with mine, for instance this one:
    <applet code="org.jdesktop.applet.util.JNLPAppletLauncher"
    width=100%
    height=98%
    archive="astrals.jar,
    http://download.java.net/media/applet-launcher/applet-launcher.jar,
    http://download.java.net/media/java3d/webstart/release/j3d/latest/j3dcore.jar,
    http://download.java.net/media/java3d/webstart/release/j3d/latest/j3dutils.jar,
    http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jar,
    http://download.java.net/media/gluegen/webstart/gluegen-rt.jar,
    http://download.java.net/media/java3d/webstart/release/vecmath/latest/vecmath.jar">
    <param name="codebase_lookup" value="false">
    <param name="subapplet.classname" value="OrchideaOptM">
    <param name="subapplet.displayname" value="Orchideic Morph">
    <param name="jnlpNumExtensions" value="1">
    <param name="jnlpExtension1" value="http://download.java.net/media/java3d/webstart/release/java3d-latest.jnlp">
    <param name="progressbar" value="true">
    <param name="noddraw.check" value="true">
    </applet>
    -----------------

  • JNLP File Generated By A Servlet

    Based on configuration issues with our system build, I have created a servlet that generates the JNLP file for an app we have created. Once the file is written and contains all the dynamically generated info, it is never written by the servlet again.
    I noticed in creating the servlet, initially, that I actually HAD to write the JNLP file. Returning the JNLP file and setting the mime type in the HTTP response was not enough. When Web Start is invoked by the browser, it goes back to the stored JNLP file on the server.
    Can anyone explain why this is necessary?? Its seems redundant. If I can create the JNLP dynamically and pass it back to the browser, why must Web Start retrieve the JNLP file AGAIN from the web server after it launches??
    John Turner
    Software Engineer
    Context Media, Inc
    [email protected]

    There is a limit to what you can do with dynamically generated JNLP files. The combination of codebase and href must exactly specify the JNLP resource that you are retrieving. If you're using a servlet with parameters in a query string to generate the file, it should look like this:
    <jnlp spec="1.0+" codebase="http://app.datadevelopment.com/app" href="MyServlet?param1=value1&param2=value2">
    As long as the MIME type returned by the servlet is "application/x-java-jnlp-file", JWS will start just fine. Unfortunately, JWS will then bomb badly because it tries to use the href attribute as part of the file name for saving the file, and Windows at least doesn't like question marks in a file name.
    A workaround is to replace the query string with path values:
    <jnlp spec="1.0+" codebase="http://app.datadevelopment.com/app" href="MyServlet/param1=value1/param2=value2">
    I'm not 100% sure that this will work with the '=' sign as my application needed only one parameter so I dispensed with the paramN=valueN and replaced the directory with valueN only. The point is, though, that each and every time the application is launched JWS will go to the web server to get the latest copy of the JNLP and the only way I have found to dynamically generate the content is to append the necessary parameters as path names after the script (JSP in my case, servlet in your case).
    If you have multiple parameters and the '=' sign is a problem, strip out the parameter name and require that the parameters be specified in the same order each time. Use one directory delimiter per parameter.
    You can use request.getPathInfo() to retrieve the path after your servlet.

  • Can application know the location of its most recent cached *jnlp* file?

    Can an application know if it was launched by clicking on the hyperlink in a web page, or whether it was launched from the shortcut on the desktop?
    Alternatively, Can the application know the location of its most recent cached jnlp file on the desktop?
    To take a specific example, let's say I have a word processor, My Word that is deployed using Web Start. It can view documents on the web and must also work offline to view local documents.
    When a user clicks the hyperlink to the doc, say,
    myParty Open the myParty document
    then myParty.jnlp launches My Word, opening the myParty.txt file.
    Since there is no way to pass arguments dynamically, one must have a jnlp file for each doc.
    So myParty.jnlp has the url of the doc hardcoded in it.
    <application-desc main-class="MyWord">
    <argument>http://www.MySite.com/myParty.doc</argument>
    </application-desc>
    The problem is that apparently Web Start uses the most recent jnlp each time it is launched.
    So that if the file has moved, or if one is offline, then the application hangs because it is trying to open the same document, regardless of whether MyWord was launched by clicking on the hyperlink in a web page - in which case this would be appropriate - or whether it was launched from the shortcut on the desktop - inappropriate here.
    As a workaround, I was wondering - where is the jnlp file stored on the local desktop?
    If the application could find the most recent jnlp, then it could rewrite it (after it was opened the first time) with an identical jnlp that has no application-desc arguments.
    Then when the user runs from the shortcut on the desktop, it will launch without a document to open.
    Any help appreciated.
    thanks,
    Anil Philip
    Are you planning to kill yourself? Stop! listen to this song
    broadband version: http://www.youtube.com/watch?v=pLHHB4YZucI
    dial-up version: http://www.youtube.com/watch?v=xL5WyBenUpM

    1) To make it more complicated, it seems that the browser also does the caching.
    2) I could not find the jnlp as a file on the desktop, so I suspect that is stored in some database. Is there any way the application can write to it or any api to simply allow the application to change the arguments?
    3) It is not an option to use jnlpservlet as the document can be placed anywhere and not just on a webserver under our control.
    Edited by: anilp1 on Mar 20, 2009 9:40 PM

Maybe you are looking for