<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>excutable jar &#8211; 記下來</title>
	<atom:link href="https://noter.tw/tag/excutable-jar/feed/" rel="self" type="application/rss+xml" />
	<link>https://noter.tw</link>
	<description>一路上踩到的坑、遇到的問題，一點一滴記下來，希望能幫助到需要的人~</description>
	<lastBuildDate>Tue, 03 Dec 2019 16:27:20 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.3</generator>

<image>
	<url>https://noter.tw/wp-content/uploads/cropped-old-1130742_1920-1-32x32.jpg</url>
	<title>excutable jar &#8211; 記下來</title>
	<link>https://noter.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Export Excutable Jar / Runnable Jar</title>
		<link>https://noter.tw/2483/export-excutable-jar-runnable-jar/</link>
					<comments>https://noter.tw/2483/export-excutable-jar-runnable-jar/#respond</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Mon, 09 May 2011 10:22:17 +0000</pubDate>
				<category><![CDATA[一般程式]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[excutable jar]]></category>
		<category><![CDATA[JAR: Could not find the main class.]]></category>
		<category><![CDATA[runnable jar]]></category>
		<category><![CDATA[Java]]></category>
		<guid isPermaLink="false">http://wazai.net/?p=2483</guid>

					<description><![CDATA[<p>用比較舊版本的 Eclipse 匯出 JAR 的時候會出現 JAR: Could not find the main class.&#160;今天把做好的 swing 專案匯出成 JAR，在桌面點兩下&#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/2483/export-excutable-jar-runnable-jar/" data-wpel-link="internal">Export Excutable Jar / Runnable Jar</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>用比較舊版本的 Eclipse 匯出 JAR 的時候會出現 <strong>JAR: Could not find the main class.</strong>&nbsp;今天把做好的 swing 專案匯出成 JAR，在桌面點兩下什麼事情都沒發生 &#8230;&nbsp;遇到問題最害怕的是什麼錯誤訊息都沒有，該從何查起 &#8230; </p>



<span id="more-2483"></span>



<p>在&nbsp;<strong><a rel="noreferrer noopener" href="https://noter.tw/2485/jar-could-not-find-the-main-class/" target="_blank" data-wpel-link="internal">JAR: Could not find the main class.</a></strong>&nbsp;中有提到，在 cmd 下輸入 java -jar xxxx.jar 就可以顯示錯誤訊息 </p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code">C:\Documents and Settings\user\桌面&gt;java -jar xpath.jar Exception in thread "main" java.lang.NoClassDefFoundError: 
com/gargoylesoftware/htmlunit/FailingHttpStatusCodeException Caused by: 
java.lang.ClassNotFoundException: 
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.net.URLClassLoader$1.run(Unknown Source)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.security.AccessController.doPrivileged(Native Method)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.net.URLClassLoader.findClass(Unknown Source)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.ClassLoader.loadClass(Unknown Source)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: xpath.tree.Xpath. Program will exit.</pre>



<p>這時候想起之前是用&nbsp;<strong><a rel="noreferrer noopener nofollow external" href="http://fjep.sourceforge.net/" target="_blank" data-wpel-link="external" class="wpel-icon-right">Fat Jar<span class="wpel-icon wpel-image wpel-icon-6"></span></a></strong>&nbsp; 搞定的，去下載了 fat jar 的 lib 之後，放入 eclipse plugin 內，成功的匯出了一個 fatjar.jar，點兩下，確定可以執行 ~&nbsp;過不久即發現 &#8230; 原來&nbsp;<strong>Eclipse 3.4</strong>&nbsp;以上就已經有包含 fat jar 了，在要匯出的專案上按<strong>右鍵</strong>&nbsp;-&gt;&nbsp;<strong>Export&nbsp;</strong>-&gt;&nbsp;<strong>Runnable JAR file</strong>，在 library handling 的部分，可以挑選自己想要的方式 </p>



<ul class="my-li bg-darkblue wp-block-list"><li><strong>Extract required libraries into generated JAR</strong><br>把所有的 import JAR 都拆開來，包含在 JAR 的各個目錄中，ex. net/org/xxx.class</li><li><strong>Package required libraries into generated JAR</strong><br>把所有的 import JAR 都包在 JAR 的根目錄下</li><li><strong>Copy required libraries into a sub-folder next to the generated JAR</strong><br>把所有 import JAR 放在 JAR 外面獨立一個資料夾</li></ul>



<p>好物一枚!!! ^__^ </p>



<h2 class="para wp-block-heading">參考資料</h2>



<ul class="my-li bg-darkblue wp-block-list"><li>JAR: Could not find the main class. @ 蛙齋<br><a href="https://noter.tw/2485/jar-could-not-find-the-main-class/" data-wpel-link="internal">https://noter.tw/2485/jar-could-not-find-the-main-class/</a></li></ul>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/2483/export-excutable-jar-runnable-jar/" data-wpel-link="internal">Export Excutable Jar / Runnable Jar</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/2483/export-excutable-jar-runnable-jar/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
