Quickly configure your Java program to Jaws (Java Web Start) (1)

zhaozj2021-02-16  49

I. Introduction to Jaws (Java Web Start) Jaws is a new application deployment mechanism that allows you to install what you need by clicking on the link on a web browser installed in the WEB browser. software. It is a transparent processing complex software installation process, which hides software on the local hard drive to execute as fast as possible when needed. Different procedures can stabilize different JDK versions, you can customize the JDK version used by your program. For the client, the JAWS plugin is responsible for downloading the latest JRE (Java Runtime Edition) version when needed. Jaws don't need any special modifications to your program to make your program run on the JAWS mechanism. However, due to the safety of safety, Jaws will put your program in a Sandbox, just like an Applet program, for a digital signature program, customers can choose trust or not trust Your program, if you choose trust, your program can access local resources like local programs (relatively), such as file systems, print systems, etc. Through the Javax.jnlp package, the procedures that are not trusted can only be used for limited system access. Jaws is based on JNLP (Java Network Launching Protocol & API), JNLP is the basic technology that defines the underlying abstraction, JAWS is an implementation. Below, you will find this mechanism by explaining how your Java program is configured. Second, the configuration

The JAWS program is configured with a web server. This is not requested a special web server, any one can, such as IIS, Apache, etc., but you have to modify your web configuration to know Application / X-java-jnlp-file. MIME type. The following is configured in the order of order, the client needs to install the JAWS plugin in advance, is JRE. 1. Packaging JAR files Your program code and data must be packaged into the JAR file, you can create a packaged JAR file through JAR tools provided by JDK1.4, as follows: JAR CVF DRAW_APPLET.JAR DRAW / * .class images / *. GIF assumes that the current directory is D: / javacode / Draw / Classes, this line command will put all extensions in the Draw directory in the current directory as a file in the image of all extensions GIF in the images directory. Packaged into the draw_applet.jar file. Of course, you can also pack your program code or data to multiple JAR files. When your program is very big, there is a significant advantage, that is, all JAR files do not have to be downloaded to the client before the program starts execution. By default, all JAR files are downloaded, but you can configure a special JAR file to download. You can also use DownloadService in the JNLP API to request to download a special JAR file. For programs that need to access client system resources, you need to use another tool Jarsigner provided by JDK to sign it to let users trust your program. 2. Establish a JNLP file JNLP is a JAWS program initial execution location. When the user clicks on a link to the JNLP file, the browser will download this JNLP file first, and the client with jaws will automatically download the program according to the indication of this file and start. In fact, JNLP file is an XML file, and its main function is to list the JAR file resource location of the program. When a JAWS program is first run, you will download all JAR files. When the JAR file on the server changes, the client JAWS program automatically downloads the changed files when the next startup, which makes the client's program to maintain the latest. The program will start directly from the client when there is no change. Below is an example of a JNLP file, this file is saved in my computer d: / javacode / draw / class directory, you can copy and modify to suit your JAWS program:

spec = "1.0 " codebase = "http://210.43.32.199/Apple/" href = "draw.jnlp"> Drawn </ Title> <! - Programmaker -> <vendor> Kevin Ma </ vendor> <! - About the web page of this program, this page's URL will be Displayed on the application manager in Jaws -> <homepage href = "http://210.43.32.199/App://210.43.32.199/Apple/drawpic.html/" /> <! - The following elements will be displayed on JAWS -> <Description > Drawn </ Description> <Description Kind = "Short"> A simple drawing software </ description> <! - Points to a JPG or GIF file URL, it will be displayed as an icon in the JAWS application manager -> <icon href = "images / draw.gif" /> <! - Declaration After being downloaded, you don't have to access the server. -> <offline-allowed /> </ information> <! - <security> Requests give enough permissions to access locally, which requires all JARs to be signed. For programs that do not access the local machine, this item is not necessary <all-permissions /> </ security> -> <resources> <! - Specifies the JRE version supported by the program. You can specify a plurality, check in priority -> <j2se version = "1.4" /> <! Specifies the relative URL of the JAR file containing code and data. -> <jar href = "draw_applet.jar" /> <! - Specifies the JAR file <jar href = "lib / backgrounds.jar" /> -> </ resources> <! - Specify the primary class of the program -> <application-desc main-class = "draw.drawpic" /> <jnlp> The meaning of each element does not need to interpret, need to explain, if you comment out <all -permissions />, that is, you declare that your program is not trusted, and accesses the local machine at runtime. It contains it means that your program is trusted, you can access the machine, but this is not to say that you can access the unit any, your program must have a digital signature and get the user's license.</p> <p>3, configure the web server in my system I use apache2. Stop it first, then open the Apache configuration file httpd.conf, find AddType Add the following line: addtype application / x-java-jnlp-file .jnlp My Java code and HTML files used in the D: / javaracode / Draw / Pub directory, you have to add an individual name in the httpd.conf file (called virtual directory in IIS) Point to it: alias / apple "D: / javaracode / DRAW / PUB <Directory "D: / JavaCode / Draw / Pub"> OptionFilter Include HTMLALLOWOVERRIDE NONE ORDER ALLOW, DENY Allow from all </ directory> Save this file and restart Apache. Then, in order to facilitate the establishment of an HTML file in D: / javacode / Draw / Pub, you list all the available JAWS programs on your server, such as: <html> <head> <title> Remote Apps WebPage </ Title> </ head> <body> <h1> remote apps webpage </ h1> <ul> <li> <a href="draw2.jnlp"> Draw </A> </ ul> <hr > <Address> <a href="mailto: cnydpl@hotmail.com"> kevin ma </a> </ address> <! - created: mon Nov 18 18:01:23 gmt 2003 -> <! - hhmts start -> Created: MON NOV 18 18:01:23 GMT 2003 <! - hhmts end -> </ body> </ html> This completes all work, at this time, all configuration work is basically Completed, then it is started.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-22558.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="22558" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.043</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'fdQh0125Ak5MHVfPQ35lyK3_2FNM5Mj6qyzisgS9vRYjTsks_2BmLBz0nk_2BNfzVblgLKHWlefxnPf8x7JUgm2zA4dw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>