<?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>java.lang.NoClassDefFoundError &#8211; 記下來</title>
	<atom:link href="https://noter.tw/tag/java-lang-noclassdeffounderror/feed/" rel="self" type="application/rss+xml" />
	<link>https://noter.tw</link>
	<description>一路上踩到的坑、遇到的問題，一點一滴記下來，希望能幫助到需要的人~</description>
	<lastBuildDate>Tue, 02 Jul 2019 05:53:27 +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>java.lang.NoClassDefFoundError &#8211; 記下來</title>
	<link>https://noter.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Java環境變數設定、記錄</title>
		<link>https://noter.tw/2496/java%e7%92%b0%e5%a2%83%e8%ae%8a%e6%95%b8%e8%a8%ad%e5%ae%9a%e3%80%81%e8%a8%98%e9%8c%84/</link>
					<comments>https://noter.tw/2496/java%e7%92%b0%e5%a2%83%e8%ae%8a%e6%95%b8%e8%a8%ad%e5%ae%9a%e3%80%81%e8%a8%98%e9%8c%84/#respond</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Tue, 17 Mar 2009 04:57:08 +0000</pubDate>
				<category><![CDATA[一般程式]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[classpath]]></category>
		<category><![CDATA[java.lang.NoClassDefFoundError]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[path]]></category>
		<category><![CDATA[環境變數]]></category>
		<guid isPermaLink="false">http://wazai.net/?p=2496</guid>

					<description><![CDATA[<p>Exception in thread &#8220;main&#8221; java.lang.NoClassDefFoundError: &#8230;..&#160;每次看到這個錯誤訊息就快抓狂&#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/2496/java%e7%92%b0%e5%a2%83%e8%ae%8a%e6%95%b8%e8%a8%ad%e5%ae%9a%e3%80%81%e8%a8%98%e9%8c%84/" data-wpel-link="internal">Java環境變數設定、記錄</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>Exception in thread &#8220;main&#8221; java.lang.NoClassDefFoundError: &#8230;..&nbsp;每次看到這個錯誤訊息就快抓狂，趁現在頭腦還清楚，用自己最容易看懂的方法記錄下來。<br />
<span id="more-2496"></span><br />
在 Windows 環境下進入 <span style="color: #ff00ff;"><strong>控制台 -&gt; 系統 -&gt;&nbsp;進階 -&gt; 系統變數</strong></span></p>
<ul>
<li>
<h3>設定 Path</h3>
<p>存一些在 cmd 下可以直接輸入的指令，例如：java, javac, ant &#8230;.&nbsp;安裝完 JDK 後，如果有設定好，就不會看到以下錯誤訊息</p>
<pre class="brush: text; gutter: true">'java' 不是內部或外部命令、
可執行的程式或批次檔。</pre>
<p>Java 方面的設定：在原有的設定裡，加上 Java 安裝目錄下的 bin 資料夾路徑，例如：安裝 JDK 1.6.0_04 版本的預設路徑為&nbsp;<span style="color: #ff0000;"><strong>C:\Program Files\Java\jdk1.6.0_04&nbsp;</strong></span>因此，在 Path 中加入<strong>&nbsp;</strong><strong>&#8220;<span style="color: #ff0000;">;C:\Program Files\Java\jdk1.6.0_04\bin</span>&#8220;</strong><strong>&nbsp;</strong><strong><br />
</strong>重新啟動一個 cmd 輸入 java 或 javac 看看，就不會再有剛剛的錯誤訊息，這邊要注意前面的「<span style="color: #ff0000;"><strong>;</strong></span>」千萬不可以省略。<br />
P.S. 安裝 ant 也是在 Path 裡加入 ant 安裝目錄下 bin 資料夾路徑。e.g. &#8220;C:\ant\bin&#8221;</li>
<li>
<h3>設定 CLASSPATH</h3>
<p>儲存一些 jar 檔的路徑，如果有使用到某個 jar 檔裡面的 packages，在編譯與執行的時候都要先設置 <span style="color: #ff0000;"><strong>-classpath</strong></span>，例如：<span style="color: #ff00ff;"><strong>javac -classpath .;C:\lib\xxxx.jar HelloWorld.java</strong></span>。可以直接設置在環境變數，就不用每次都要指定 -classpath。</p>
<pre class="brush: text; gutter: true">Exception in thread "main" java.lang.NoClassDefFoundError:</pre>
<p>看到上面這個錯誤訊息，多半是因為 classpath 沒設定好(搞好久) = =&nbsp;設定為：<strong>&#8220;<span style="color: #ff0000;">.;C:\Program Files\Java\jdk1.6.0_04\lib\tools.jar;</span>&#8220;</strong>&nbsp;分號後面自己增加要使用的 jar file<br />
P.S. 分號最前面的 「<span style="color: #ff0000;"><strong>.</strong></span>」 不可遺漏，表示從目前目錄尋找 class</li>
<li>
<h3>紀錄：使用 package</h3>
<p>例如：透過 package com.test 把 hello.java 產生的 class 檔打包。在 C:\java\ 下編譯 =&gt; &#8220;javac -d . hello.java&#8221;，class 會編譯完會出現在 C:\java\com\test\hello.class，這時候要執行 hello 就必須在 C:\java\ 下透過 &#8220;java com.test.hello&#8221; 才能執行，直接輸入 &#8220;java hello&#8221; 或是到 C:\java\com\test\ 下輸入 &#8220;java hello&#8221; 是不行的。</li>
</ul>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/2496/java%e7%92%b0%e5%a2%83%e8%ae%8a%e6%95%b8%e8%a8%ad%e5%ae%9a%e3%80%81%e8%a8%98%e9%8c%84/" data-wpel-link="internal">Java環境變數設定、記錄</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/2496/java%e7%92%b0%e5%a2%83%e8%ae%8a%e6%95%b8%e8%a8%ad%e5%ae%9a%e3%80%81%e8%a8%98%e9%8c%84/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
