{"id":291,"date":"2024-02-12T20:34:12","date_gmt":"2024-02-13T01:34:12","guid":{"rendered":"https:\/\/keishoseiho.com\/?p=291"},"modified":"2024-11-07T12:56:52","modified_gmt":"2024-11-07T17:56:52","slug":"java-study-room","status":"publish","type":"post","link":"https:\/\/keishoseiho.com\/index.php\/2024\/02\/12\/java-study-room\/","title":{"rendered":"Java Study Room"},"content":{"rendered":"\n<p>Pseudo login-signup Java toy<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/drive.google.com\/file\/d\/1dciGTcO-fatzX8LPDnEM7fYDdTCA0Ynd\/view?usp=drive_link\" target=\"_blank\" rel=\"noreferrer noopener\">Download<\/a><\/div>\n<\/div>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>I built a jar package and converted it to .exe, with jdk21(a watered-down version I deleted some parts), &#8220;CRUD&#8221; without database access. As jdk21 doesn&#8217;t separate the JRE file, the supporting jdk21 file is too big(about 180MB) to put in GitHub(limit 100MB). My file size is 210MB.<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Is it really &#8220;Write once, run anywhere&#8221; ?<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"462\" height=\"182\" src=\"https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-13.png\" alt=\"\" class=\"wp-image-295\" srcset=\"https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-13.png 462w, https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-13-300x118.png 300w\" sizes=\"auto, (max-width: 462px) 100vw, 462px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"677\" height=\"567\" src=\"https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-14.png\" alt=\"\" class=\"wp-image-296\" srcset=\"https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-14.png 677w, https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-14-300x251.png 300w, https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-14-600x503.png 600w\" sizes=\"auto, (max-width: 677px) 100vw, 677px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"717\" height=\"593\" src=\"https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-15.png\" alt=\"\" class=\"wp-image-297\" srcset=\"https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-15.png 717w, https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-15-300x248.png 300w, https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-15-600x496.png 600w\" sizes=\"auto, (max-width: 717px) 100vw, 717px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p>JRE file extracting<\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0);color:#862feb\" class=\"has-inline-color\">I tried to use jlink to separate the jre file(~80MB) from jdk21, but the jre file does not support my exe file.<br>use Windows PowerShell or Command Prompt get jre file: * Run as Administrator is necessary or Error<\/mark><\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<p>cd &#8220;C:\\Program Files\\Java\\jdk-21&#8221;<br \/>\nbin\\jlink.exe &#8211;module-path jmods &#8211;add-modules java.desktop &#8211;output jre<\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Before &amp; After<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"102\" height=\"361\" src=\"https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-17.png\" alt=\"\" class=\"wp-image-302\" style=\"width:165px;height:auto\" srcset=\"https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-17.png 102w, https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-17-85x300.png 85w\" sizes=\"auto, (max-width: 102px) 100vw, 102px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"105\" height=\"401\" src=\"https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-19.png\" alt=\"\" class=\"wp-image-304\" style=\"width:165px;height:auto\"\/><\/figure>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><a href=\"https:\/\/javaalmanac.io\/bytecode\/versions\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Class File Versions<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"333\" height=\"722\" src=\"https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-20.png\" alt=\"\" class=\"wp-image-305\" srcset=\"https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-20.png 333w, https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/image-20-138x300.png 138w\" sizes=\"auto, (max-width: 333px) 100vw, 333px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Each JDK Release comes with its class file version. Class files are backward compatible. But class files compiled for newer JDK releases cannot be executed and will result in an <code>UnsupportedClassVersionError<\/code>.<\/p>\n\n\n\n<p>The table lists class file versions for each JDK release. Follow the linked JDK information to find download options for a suitable JDK.<\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-main-primary-dark-color\">The latest version JRE I can find is Java 8, which supports class file version ~52, but can&#8217;t support a higher version, that&#8217;s why I extracted the JRE file from JDK21(Java21). I wanted a support file for my JavaFX jar file, but I didn&#8217;t find the way.<\/mark><\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-main-primary-dark-color\">I gave up compression of the size and put a big part of JDK21 to support my exe (converted from JavaFX jar) file.<\/mark><\/p>\n<\/div>\n<\/div>\n\n\n\n<div style=\"height:70px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>2024\/08\/01<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/drive.google.com\/file\/d\/18BZOjLiqbJsaS0FwCG-6CFYaXGFi2KVD\/view?usp=sharing\">RedKnightClub_ver1.1 download<\/a><\/div>\n<\/div>\n\n\n\n<p>Modularization was hard when I use an external library&#8230;<\/p>\n\n\n\n<p> <\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"334\" height=\"627\" src=\"https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/Screenshot-2024-08-01-204436-1.png\" alt=\"\" class=\"wp-image-490\" style=\"width:314px;height:auto\" srcset=\"https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/Screenshot-2024-08-01-204436-1.png 334w, https:\/\/keishoseiho.com\/wp-content\/uploads\/2024\/02\/Screenshot-2024-08-01-204436-1-160x300.png 160w\" sizes=\"auto, (max-width: 334px) 100vw, 334px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>I improved the way to extract the necessary file for running javafx, the size of the total was reduced to <strong>190 MB<\/strong> (20MB cut). I examined the necessary external library jar file and a bin file which I combined with the other bin file extracted by jlink.<\/p>\n\n\n\n<p>I arranged the 4 jar file on the module path (in the mods file), and compiled\/modularization my main source file to the same module path.<\/p>\n\n\n\n<p>Then, I extracted Knight(=jre) for the main module, but the bin of JavaFX comes from an external library and this should be combine with the Knight file.<\/p>\n\n\n\n<p> <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>jlink -p mods --add-modules mian --output Knight<\/code><\/pre>\n<\/div>\n<\/div>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Pseudo login-signup Java toy I built a jar package and converted it to .exe, with jdk21(a watered-down version I deleted some parts), &#8220;CRUD&#8221; without database access. As jdk21 doesn&#8217;t separate the JRE file, the supporting jdk21 file is too big(about 180MB) to put in GitHub(limit 100MB). My file size is 210MB. Is it really &#8220;Write [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":507,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-291","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/keishoseiho.com\/index.php\/wp-json\/wp\/v2\/posts\/291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/keishoseiho.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/keishoseiho.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/keishoseiho.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/keishoseiho.com\/index.php\/wp-json\/wp\/v2\/comments?post=291"}],"version-history":[{"count":15,"href":"https:\/\/keishoseiho.com\/index.php\/wp-json\/wp\/v2\/posts\/291\/revisions"}],"predecessor-version":[{"id":508,"href":"https:\/\/keishoseiho.com\/index.php\/wp-json\/wp\/v2\/posts\/291\/revisions\/508"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/keishoseiho.com\/index.php\/wp-json\/wp\/v2\/media\/507"}],"wp:attachment":[{"href":"https:\/\/keishoseiho.com\/index.php\/wp-json\/wp\/v2\/media?parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/keishoseiho.com\/index.php\/wp-json\/wp\/v2\/categories?post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/keishoseiho.com\/index.php\/wp-json\/wp\/v2\/tags?post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}