Results 1 to 7 of 7
  1. #1
    asai is offline Senior Member
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    135
    Rep Power
    0

    Default Run jar files from webpage

    Hi,

    I am trying to run a java app from a webpage.
    The java app is written with Netbeans.

    Heres my files:

    Java main class:
    Java Code:
    package Classes;
    
    import java.applet.Applet;
    
    public class Start extends Applet{
    
        public static void main(String[] args) {
            System.out.println("Hello world");
        }
        
    }
    JNLP file:
    Java Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <jnlp codebase="$$codebase" href="launch.jnlp" spec="1.0+">
        <information>
            <title>Webtest</title>
            <vendor>Terje</vendor>
            <homepage href=""/>
            <description>Webtest</description>
            <description kind="short">Webtest</description>
        </information>
        <update check="always"/>
        <security>
    <all-permissions/>
    </security>
        <resources>
            <j2se version="1.8+"/>
            <jar href="Webtest.jar" main="true"/>
        </resources>
        <application-desc main-class="Classes.Start">
        </application-desc>
    </jnlp>
    HTML file:
    Java Code:
    <html>
        <head>
            <title>Test page for launching the application via JNLP</title>
        </head>
        <body>
            <h3>Test page for launching the application via JNLP</h3>
            <script src="http://java.com/js/deployJava.js"></script>
            <script>
                deployJava.createWebStartLaunchButton("launch.jnlp")
            </script>
            <!-- Or use the following link element to launch with the application -->
            <!--
            <a href="launch.jnlp">Launch the application</a>
            -->
        </body>
    </html>
    You can test the page here: Test page for launching the application via JNLP

    Something is missing, but I can't find the missing piece. Anyone that can give me a little help on my way?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Run jar files from webpage

    Something is missing,
    Please explain. If you are getting error messages, please copy the full text and paste it here.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    asai is offline Senior Member
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    135
    Rep Power
    0

    Default Re: Run jar files from webpage

    Unable to launch the application.
    Details:
    Java Code:
    om.sun.deploy.net.FailedDownloadException: Unable to load resource: file:/C:/Users/terje.halvorsen/AppData/Local/Microsoft/Windows/Temporary Internet Files/Content.IE5/ORNIOJH7/$$codebase/launch.jnlp
    	at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
    	at com.sun.deploy.net.DownloadEngine.downloadResource(Unknown Source)
    	at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
    	at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
    	at com.sun.javaws.Launcher.updateFinalLaunchDesc(Unknown Source)
    	at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    	at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    	at com.sun.javaws.Launcher.launch(Unknown Source)
    	at com.sun.javaws.Main.launchApp(Unknown Source)
    	at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    	at com.sun.javaws.Main.access$000(Unknown Source)
    	at com.sun.javaws.Main$1.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Run jar files from webpage

    I'm guessing it is that odd '$$codebase' value. Note how that same value ends up in the temporary internet files path. Do a test with an empty codebase.

    Java Code:
    <jnlp codebase="" href="launch.jnlp" spec="1.0+">
    ...
    For safety clear your internet cache first. If that doesn't change anything, test it with another browser that is not internet explorer to see if that makes any difference.

    Unrelated note: the code you posted is not a proper applet. I don't know what resource you are using to learn all this but it may be incredibly outdated and wrong.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    asai is offline Senior Member
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    135
    Rep Power
    0

    Default Re: Run jar files from webpage

    Thanks for the replies.
    Where can I find good resources for learning to make proper applets?
    When I tried your suggestion, the error changed. Now the error is that the jar file is not found. The jar file is located in the same directory on the webserver as the jnlp and html file.

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Run jar files from webpage

    Here is a good place to start: How to Make Applets (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

    That covers creating a -Swing- applet, which you do by using the class 'JApplet' and not 'Applet' as you are doing now.

    As to your next error: you are putting the file with an uppercase in your jnlp file, 'Webtest.jar'. Is that really the filename, or is it all lowercase 'webtest.jar' ?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Run jar files from webpage

    And since you will probably run into it eventually, check out this thread.

    http://www.java-forums.org/java-appl...t-legally.html

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. run jsp page as a webpage
    By ssuman02 in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 08-09-2013, 03:57 PM
  2. WebPage to XML
    By sandeep424 in forum Web Frameworks
    Replies: 0
    Last Post: 06-15-2012, 06:23 PM
  3. loading webpage
    By juhiswt in forum New To Java
    Replies: 0
    Last Post: 03-17-2011, 06:37 PM
  4. Add a Swing UI in a WebPage
    By ivvgangadhar in forum AWT / Swing
    Replies: 9
    Last Post: 06-30-2009, 08:16 AM
  5. save a webpage.....?
    By 05bit044 in forum Networking
    Replies: 1
    Last Post: 08-04-2008, 04:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •