{"id":617,"date":"2021-04-14T18:37:41","date_gmt":"2021-04-14T18:37:41","guid":{"rendered":"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/?page_id=617"},"modified":"2021-04-14T18:56:30","modified_gmt":"2021-04-14T18:56:30","slug":"bean-deployment","status":"publish","type":"page","link":"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/course-topics\/java-beans\/bean-deployment\/","title":{"rendered":"Bean Deployment"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a6d480db78a4\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a6d480db78a4\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/course-topics\/java-beans\/bean-deployment\/#The_jar_Program\" >The jar Program<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/course-topics\/java-beans\/bean-deployment\/#Examples\" >Examples<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/course-topics\/java-beans\/bean-deployment\/#Creating_a_jar_File\" >Creating a&nbsp;jar&nbsp;File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/course-topics\/java-beans\/bean-deployment\/#Listing_a_jar_File\" >Listing a&nbsp;jar&nbsp;File<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/course-topics\/java-beans\/bean-deployment\/#The_Manifest\" >The Manifest<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/course-topics\/java-beans\/bean-deployment\/#Specifying_a_Manifest_File\" >Specifying a Manifest File<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n<p class=\"wp-block-paragraph\">When you wish to add a Java Bean to an application, or to any other similar tool, you have to&nbsp;<em>deploy<\/em>&nbsp;it properly. This means adding all the files that the Bean uses (.class&nbsp;files,&nbsp;.gif&nbsp;files, etc) into a <em>Java Archive<\/em>, or&nbsp;jar, file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_jar_Program\"><\/span>The jar Program<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The&nbsp;jar&nbsp;program is provided as part of the Java JDK. Like most other programs supplied with the JDK, it has a UNIX-style command line interface, which is not particularly user-friendly. Most Java IDE vendors also provide it (or something equivalent), but usually implement an easier interface to it from their IDE.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can find a number of examples of&nbsp;<strong>make<\/strong>&nbsp;files which you can use as models for constructing your own make files for your own Java Beans. Using&nbsp;<strong>make<\/strong>&nbsp;is usually far preferable to learning such arcane interfaces.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The command line interface looks like:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>jar {ctx}[vfm0M] [jar-file] [manifest-file] files ...<\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The first command line argument consists of a set of single-character&nbsp;<em>options<\/em>. One, and only one, of the required command options (<strong>c<\/strong>,&nbsp;<strong>t<\/strong>, or&nbsp;<strong>x<\/strong>) may be selected at a time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The remainder of the options may be combined or omitted, as necessary.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th><strong>Option<\/strong><\/th><th><strong>Description<\/strong><\/th><\/tr><tr><td><strong>c<\/strong><\/td><td>Create a new archive file<\/td><\/tr><tr><td><strong>t<\/strong><\/td><td>List the table of contents for the archive file<\/td><\/tr><tr><td><strong>x<\/strong><\/td><td>Extract the named files from the archive. If no filenames are specified, all files are extracted.<\/td><\/tr><tr><td><strong>v<\/strong><\/td><td>Generate verbose output<\/td><\/tr><tr><td><strong>f<\/strong><\/td><td>Specify the archive filename following the options. If this option is not used, standard in and standard out are used.<\/td><\/tr><tr><td><strong>m<\/strong><\/td><td>Include manifest information from the specified manifest file.<\/td><\/tr><tr><td><strong>0<\/strong><\/td><td>Do not use compression.<\/td><\/tr><tr><td><strong>M<\/strong><\/td><td>Do not create a manifest file for the archive entries<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The optional&nbsp;<strong>jar-file<\/strong>&nbsp;argument specifies the name of the archive file. If you use the&nbsp;<strong>f<\/strong>&nbsp;option, this argument should be present. Note that (as is true for many UNIX utilities), there are no required naming rules for jar files. In particular, if you wish a&nbsp;.jar&nbsp;filetype, you must be explicit about it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The optional&nbsp;<strong>manifest-file<\/strong>&nbsp;argument specifies the name of a file that contains the manifest information to be used for the archive. If you use the <strong>m<\/strong> option, this argument should be present. For details on the contents of this manifest file, see&nbsp;<a href=\"#the-manifest\" data-type=\"internal\" data-id=\"#the-manifest\">The Manifest<\/a>, below.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After the jar-file and manifest-file arguments, follow the filenames to be archived. Multiple filenames are separated by whitespace, and you can use wildcards, as needed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You may not remove an entry from, nor add an entry to, an existing JAR file &#8212; each time you want to do that, you must recreate the entire file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Examples\"><\/span>Examples<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Creating_a_jar_File\"><\/span>Creating a&nbsp;jar&nbsp;File<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>jar cf MyBean.jar MyBean.class<\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">(when executed in the directory where the&nbsp;<strong>MyBean.class<\/strong>&nbsp;file exists) creates a new archive,&nbsp;<strong>MyBean.jar<\/strong>, containing the file&nbsp;<strong>MyBean.class<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Another example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>jar cvf BeanLibrary.jar myBeans\/classes\/*.class<\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">creates a new archive, <strong>BeanLibrary.jar,<\/strong> containing all the .class files in the myBeans\/classes subdirectory of the directory from where the command is executed. The&nbsp;<strong>v<\/strong>&nbsp;option causes something like:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>adding: myBeans\/classes\/FromageDistributorBean.class in=2999 out=1507\ndeflated 49.0%<\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">to be output on standard out, for each file added to the archive.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Listing_a_jar_File\"><\/span>Listing a&nbsp;jar&nbsp;File<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The command<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>jar tvf ColorBar.jar<\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">will output on standard out something like:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>   820 Sat Apr 08 13:47:00 EDT 2000 META-INF\/MANIFEST.MF\n     0 Sat Apr 08 13:47:00 EDT 2000 javaBeans\/\n  2228 Sat Apr 08 13:47:00 EDT 2000 javaBeans\/IntBox.class\n   944 Sat Apr 08 13:47:00 EDT 2000 javaBeans\/ColorBarApplet$1.class\n  3377 Sat Apr 08 13:47:00 EDT 2000 javaBeans\/BarChart.class\n  1745 Sat Apr 08 13:47:00 EDT 2000 javaBeans\/ColorBarApplet.class\n  1265 Sat Apr 08 13:47:00 EDT 2000 javaBeans\/ColorBar.class<\/strong><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-manifest\"><span class=\"ez-toc-section\" id=\"The_Manifest\"><\/span>The Manifest<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The\u00a0jar\u00a0utility automatically generates a manifest when the archive is created, unless you specify the <strong>M<\/strong> option. The name of the manifest is always\u00a0<strong>MANIFEST.MF<\/strong>\u00a0and it is always placed into a directory\u00a0<strong>META-INF<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The manifest contains one or more sections, each one describing an entry in the archive. Sections are separated by a blank line. For example, here is the manifest for the above ColorBar.jar file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Manifest-Version: 1.0\n\nName: javaBeans\/ColorBarApplet.class\nJava-Bean: True\nDigest-Algorithms: SHA MD5 \nSHA-Digest: dJzolmQMY\/ROREoe+3g6yDek74c=\nMD5-Digest: bk8bOtTGLsUXgSvGZvkVSw==\n\nName: javaBeans\/ColorBar.class\nJava-Bean: True\nDigest-Algorithms: SHA MD5 \nSHA-Digest: u2opYIh3iPV3I\/zL1trCIAewomU=\nMD5-Digest: ySp487LPYwRoH7ALDxHo5Q==\n\nName: javaBeans\/ColorBarApplet$1.class\nDigest-Algorithms: SHA MD5 \nSHA-Digest: 9ZbCTRD1yj+anZSF8yqM3vCas3k=\nMD5-Digest: Ptp9iNw0ME2erBbhdw2EQQ==\n\nName: javaBeans\/BarChart.class\nJava-Bean: True\nDigest-Algorithms: SHA MD5 \nSHA-Digest: pbVzI\/6\/i\/AWWymh8GsAsh6LJXY=\nMD5-Digest: tn8YFEskhBBXagDnQfBx8A==\n\nName: javaBeans\/IntBox.class\nJava-Bean: True\nDigest-Algorithms: SHA MD5 \nSHA-Digest: JMZiL+AeOOm0YDTG2TKYr\/e+ZQg=\nMD5-Digest: DNSTTzEtQqldicVjBh9R7w==<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Each section in the manifest contains a series of attribute\/value pairs<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>attribute-name: value<\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The first section in the manifest identifies the manifest version used by the archive.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Each of the subsequent sections describe an element in the archive (not including the manifest itself) Most of the information has to do with the digest algorithms and resulting hash values for the element.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The most important attribute for our current purposes is:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>Java-Bean: True<\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">which is how the elements in the archive that are Java Beans are identified as such, by other programs.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Specifying_a_Manifest_File\"><\/span>Specifying a Manifest File<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">If you don&#8217;t supply a manifest,&nbsp;jar&nbsp;will generate one for you, unless you specify the&nbsp;<strong>M<\/strong>&nbsp;option.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to specify that one or more of your classes is a Bean, then you have to create a manifest yourself. However, you don&#8217;t have to describe every element, nor even all the attributes for an entry. Here&#8217;s an example of what was specified when <strong>ColorBar.jar<\/strong> was created:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Manifest-Version: 1.0\n\nName: javaBeans\/ColorBarApplet.class\nJava-Bean: True\n\nName: javaBeans\/ColorBar.class\nJava-Bean: True\n\nName: javaBeans\/BarChart.class\nJava-Bean: True\n\nName: javaBeans\/IntBox.class\nJava-Bean: True<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then you can use the command (typed on a single, very long line):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>jar cfm ColorBar.jar ColorBar.mf javaBeans\/ColorBarApplet.class\n\t\t\t\t javaBeans\/ColorBar.class\n\t\t\t\t javaBeans\/ColorBarApplet$1.class\n\t\t\t\t javaBeans\/BarChart.class\n\t\t\t\t javaBeans\/IntBox.class<\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">to create the archive file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you wish to add a Java Bean to an application, or to any other similar tool, you have to&nbsp;deploy&nbsp;it properly. This means adding all the files that the Bean uses (.class&nbsp;files,&nbsp;.gif&nbsp;files, etc) into a Java Archive, or&nbsp;jar, file. The jar Program The&nbsp;jar&nbsp;program is provided as part of the Java JDK. Like most other programs [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":572,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_eb_attr":"","ocean_front_end_style_editor":"no","ocean_post_layout":"left-sidebar","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"ocs-course-topics-sidebar","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","footnotes":""},"class_list":["post-617","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/wp-json\/wp\/v2\/pages\/617","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/wp-json\/wp\/v2\/comments?post=617"}],"version-history":[{"count":3,"href":"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/wp-json\/wp\/v2\/pages\/617\/revisions"}],"predecessor-version":[{"id":623,"href":"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/wp-json\/wp\/v2\/pages\/617\/revisions\/623"}],"up":[{"embeddable":true,"href":"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/wp-json\/wp\/v2\/pages\/572"}],"wp:attachment":[{"href":"https:\/\/bhiggs.x10hosting.com\/HighOctaneJava\/wp-json\/wp\/v2\/media?parent=617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}