J2PrinterWebStartTest Application --------------------------------- Windows version. (For Mac OS X see "Mac OS X/J2PrinterWebStartTest".) Brief Description: This sample demonstrates the use of the J2PrinterWorks class J2PrinterWebStart which enables J2PrinterWorks-based printing from Java Web Start applications. The following JNLP API is used by the Application: PrintService: This interface provides methods for access to JNLP printing functions. In particular, the methods showPageFormatDialog(PageFormat) and print(Pageable) are used. For information on Java Web Start and the JNLP API, please check the Sun online documentation at http://java.sun.com/products/javawebstart/developers.html or http://java.sun.com/javase/technologies/desktop/javawebstart/index.jsp. Files for J2PrinterWebStartTest (Windows): src - This directory contains the required source file, J2PrinterWebStartTest.java, and a manifest file for the jar build process. classes - This directory contains .class files generated by the build process. dist - This directory contains all the files required for running the Web Start application. readme.txt - This file. Win build commands.txt - This file contains Windows command templates for building and running the J2PrinterWebStartTest application. Provide paths from your system. Building & Testing J2PrinterWebStartTest: 1) In the file /dist/J2PrinterWebStartTest.jnlp modify the tag "codebase=" to point to the location on your web server where J2PrinterWebStartTest will be installed, e.g. codebase="http://www.yourwebsite.com/~user/J2PrinterWebStartTest" Alternatively, to run J2PrinterWebStartTest locally from the command line, modify the tag "codebase=" to point to the /dist location in the filesystem, e.g. codebase="file:///C:/J2PrinterWebStartTest/dist" 2) Place a copy of J2PrinterWorks.jar into the folder /dist. A template copy command is in the file "Win build commands.txt". 3) Using the template commands in the file "Win build commands.txt", enter the build commands at the Windows command line. Generated classes will go into the classes directory, and jar files will be in the dist directory. Verify that the /dist folder contains these files: index.html J2PrinterWebStartTest.jar J2PrinterWebStartTest.jnlp J2PrinterWorks.jar 4) Java Web Start printing with J2PrinterWorks requires permission to access J2PrinterWorks.jar. For testing it is most convenient to modify your javaws.policy file in the JRE lib/security directory; add this permission to the policy file: grant { permission java.security.AllPermission; }; For deployment, the application jar file (including J2PrinterWorks.jar) should be signed. See the J2PrinterWorks FAQ for signing Java Web Start applications. 5) To test, copy the /dist folder to the specified location on your web server, e.g. /J2PrinterWebStartTest/dist Then in your browser, navigate to index.html in the dist location. Click on the "Launch Application" link to start the application, or you can double-click /dist/J2PrinterWebStartTest.jnlp Alternatively, to run J2PrinterWebStartTest from the command line, set your command location to the dist directory and run javaws from the JRE or JDK installation, e.g. C:\Java\jre1.6\bin\javaws J2PrinterWebStartTest.jnlp Deployment of Application: For deployment of applications to any J2EE-compliant server, the resources required, including .jnlp and jar files, can be packed into a Web Archive (.war) file. The Sun Java Web Start sample applications in the JDK 1.5 or 1.6 directory sample/jnlp have general deployment information. Consult your application server documentation for specific Web Start deployment instructions.