<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.4.2-rc) on Fri Jun 13 00:14:20 PDT 2003 -->
<TITLE>
ClassNotFoundException (Java 2 Platform SE v1.4.2)
</TITLE>
<META NAME="keywords" CONTENT="java.lang.ClassNotFoundException class">
<META NAME="keywords" CONTENT="getException()">
<META NAME="keywords" CONTENT="getCause()">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
parent.document.title="ClassNotFoundException (Java 2 Platform SE v1.4.2)";
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/ClassNotFoundException.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.4.2</b></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../java/lang/ClassCastException.html" title="class in java.lang"><B>PREV CLASS</B></A>
<A HREF="../../java/lang/CloneNotSupportedException.html" title="class in java.lang"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../index.html" target="_top"><B>FRAMES</B></A>
<A HREF="ClassNotFoundException.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
java.lang</FONT>
<BR>
Class ClassNotFoundException</H2>
<PRE>
<A HREF="../../java/lang/Object.html" title="class in java.lang">java.lang.Object</A>
<IMG SRC="../../resources/inherit.gif" ALT="extended by"><A HREF="../../java/lang/Throwable.html" title="class in java.lang">java.lang.Throwable</A>
<IMG SRC="../../resources/inherit.gif" ALT="extended by"><A HREF="../../java/lang/Exception.html" title="class in java.lang">java.lang.Exception</A>
<IMG SRC="../../resources/inherit.gif" ALT="extended by"><B>java.lang.ClassNotFoundException</B>
</PRE>
<DL>
<DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../java/io/Serializable.html" title="interface in java.io">Serializable</A></DD>
</DL>
<HR>
<DL>
<DT>public class <B>ClassNotFoundException</B><DT>extends <A HREF="../../java/lang/Exception.html" title="class in java.lang">Exception</A></DL>
<P>
Thrown when an application tries to load in a class through its
string name using:
当一个应用试图按以下方式使用字符串加载类时:
<ul>
<li>The <code>forName</code> method in class <code>Class</code>. Class类的forName方法。
<li>The <code>findSystemClass</code> method in class
<code>ClassLoader</code> . ClassLoader类的findSystemClass方法。
<li>The <code>loadClass</code> method in class <code>ClassLoader</code>. ClassLoader类的loadClass方法。
</ul>
<p>
but no definition for the class with the specified name could be found.
但未找到指定名称的类定义时抛出。
<p>As of release 1.4, this exception has been retrofitted to conform to
the general purpose exception-chaining mechanism. The "optional exception
that was raised while loading the class" that may be provided at
construction time and accessed via the <A HREF="../../java/lang/ClassNotFoundException.html#getException()"><CODE>getException()</CODE></A> method is
now known as the <i>cause</i>, and may be accessed via the <A HREF="../../java/lang/Throwable.html#getCause()"><CODE>Throwable.getCause()</CODE></A> method, as well as the aforementioned "legacy method."
在1.4版本中,该异常已被更新以符合通常的异常链机制。在构造时提供“当载入类时,引发的可选异常”,
并且通过getException()方法存取cause,也可以通过Throwable.getCause()方法存取,和从上述方法继承一样。
<P>
<P>
<DL>
<DT><B>Since:</B></DT>
<DD>JDK1.0</DD>
<DT><B>See Also:</B><DD><A HREF="../../java/lang/Class.html#forName(java.lang.String)"><CODE>Class.forName(java.lang.String)</CODE></A>,
<A HREF="../../java/lang/ClassLoader.html#findSystemClass(java.lang.String)"><CODE>ClassLoader.findSystemClass(java.lang.String)</CODE></A>,
<A HREF="../../java/lang/ClassLoader.html#loadClass(java.lang.String, boolean)"><CODE>ClassLoader.loadClass(java.lang.String, boolean)</CODE></A>,
<A HREF="../../serialized-form.html#java.lang.ClassNotFoundException">Serialized Form</A></DL>
<HR>
<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->
<!-- =========== FIELD SUMMARY =========== -->
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../java/lang/ClassNotFoundException.html#ClassNotFoundException()">ClassNotFoundException</A></B>()</CODE>
<BR>
Constructs a <code>ClassNotFoundException</code> with no detail message.
创建一个不含详细信息的ClassNotFoundException。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../java/lang/ClassNotFoundException.html#ClassNotFoundException(java.lang.String)">ClassNotFoundException</A></B>(<A HREF="../../java/lang/String.html" title="class in java.lang">String</A> s)</CODE>
<BR>
Constructs a <code>ClassNotFoundException</code> with the
specified detail message.创建一个指定详细信息的ClassNotFoundException。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../java/lang/ClassNotFoundException.html#ClassNotFoundException(java.lang.String, java.lang.Throwable)">ClassNotFoundException</A></B>(<A HREF="../../java/lang/String.html" title="class in java.lang">String</A> s,
<A HREF="../../java/lang/Throwable.html" title="class in java.lang">Throwable</A> ex)</CODE>
<BR>
Constructs a <code>ClassNotFoundException</code> with the
specified detail message and optional exception that was
raised while loading the class.
创建一个指定详细信息并且在载入类时引发可选异常的ClassNotFoundException。</TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../java/lang/Throwable.html" title="class in java.lang">Throwable</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/lang/ClassNotFoundException.html#getCause()">getCause</A></B>()</CODE>
<BR>
Returns the the cause of this exception (the exception that was raised
if an error occurred while attempting to load the class; otherwise
<tt>null</tt>).
返回引起该异常的原因(当载入类时,如果发生错误,返回引起的异常,否则为null)。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> <A HREF="../../java/lang/Throwable.html" title="class in java.lang">Throwable</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/lang/ClassNotFoundException.html#getException()">getException</A></B>()</CODE>
<BR>
Returns the exception that was raised if an error occurred while
attempting to load the class.
当载入类时,如果发生一个错误,返回该错误引起的异常。</TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_java.lang.Throwable"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.lang.<A HREF="../../java/lang/Throwable.html" title="class in java.lang">Throwable</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../java/lang/Throwable.html#fillInStackTrace()">fillInStackTrace</A>, <A HREF="../../java/lang/Throwable.html#getLocalizedMessage()">getLocalizedMessage</A>, <A HREF="../../java/lang/Throwable.html#getMessage()">getMessage</A>, <A HREF="../../java/lang/Throwable.html#getStackTrace()">getStackTrace</A>, <A HREF="../../java/lang/Throwable.html#initCause(java.lang.Throwable)">initCause</A>, <A HREF="../../java/lang/Throwable.html#printStackTrace()">printStackTrace</A>, <A HREF="../../java/lang/Throwable.html#printStackTrace(java.io.PrintStream)">printStackTrace</A>, <A HREF="../../java/lang/Throwable.html#printStackTrace(java.io.PrintWriter)">printStackTrace</A>, <A HREF="../../java/lang/Throwable.html#setStackTrace(java.lang.StackTraceElement[])">setStackTrace</A>, <A HREF="../../java/lang/Throwable.html#toString()">toString</A></CODE></TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.lang.<A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../java/lang/Object.html#clone()">clone</A>, <A HREF="../../java/lang/Object.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/lang/Object.html#finalize()">finalize</A>, <A HREF="../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../java/lang/Object.html#hashCode()">hashCode</A>, <A HREF="../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../java/lang/Object.html#wait(long)">wait</A>, <A HREF="../../java/lang/Object.html#wait(long, int)">wait</A></CODE></TD>
</TR>
</TABLE>
<P>
<!-- ============ FIELD DETAIL =========== -->
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="ClassNotFoundException()"><!-- --></A><H3>
ClassNotFoundException</H3>
<PRE>
public <B>ClassNotFoundException</B>()</PRE>
<DL>
<DD>Constructs a <code>ClassNotFoundException</code> with no detail message.
创建一个不含详细信息的ClassNotFoundException。
<P>
</DL>
<HR>
<A NAME="ClassNotFoundException(java.lang.String)"><!-- --></A><H3>
ClassNotFoundException</H3>
<PRE>
public <B>ClassNotFoundException</B>(<A HREF="../../java/lang/String.html" title="class in java.lang">String</A> s)</PRE>
<DL>
<DD>Constructs a <code>ClassNotFoundException</code> with the
specified detail message.
创建一个指定详细信息的ClassNotFoundException。
<P>
<DT><B>Parameters:</B><DD><CODE>s</CODE> - the detail message.详细信息。</DL>
<HR>
<A NAME="ClassNotFoundException(java.lang.String, java.lang.Throwable)"><!-- --></A><H3>
ClassNotFoundException</H3>
<PRE>
public <B>ClassNotFoundException</B>(<A HREF="../../java/lang/String.html" title="class in java.lang">String</A> s,
<A HREF="../../java/lang/Throwable.html" title="class in java.lang">Throwable</A> ex)</PRE>
<DL>
<DD>Constructs a <code>ClassNotFoundException</code> with the
specified detail message and optional exception that was
raised while loading the class.
创建一个指定详细信息并且在载入类时引发可选异常的ClassNotFoundException。
<P>
<DT><B>Parameters:</B><DD><CODE>s</CODE> - the detail message 详细信息<DD><CODE>ex</CODE> - the exception that was raised while loading the class 当载入类时引起的异常<DT><B>Since:</B></DT>
<DD>1.2</DD>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="getException()"><!-- --></A><H3>
getException</H3>
<PRE>
public <A HREF="../../java/lang/Throwable.html" title="class in java.lang">Throwable</A> <B>getException</B>()</PRE>
<DL>
<DD>Returns the exception that was raised if an error occurred while
attempting to load the class. Otherwise, returns <tt>null</tt>.
返回当试图加载类时发生错误引发的异常,否则为null。
<p>This method predates the general-purpose exception chaining facility.
The <A HREF="../../java/lang/Throwable.html#getCause()"><CODE>Throwable.getCause()</CODE></A> method is now the preferred means of
obtaining this information.
该方法可以方便地将异常填入异常列表,Throwable.getCause()方法是首选的获得该信息的手段。
<DD><DL>
<DT><B>Returns:</B><DD>the <code>Exception</code> that was raised while loading a class
加载类时引发的异常<DT><B>Since:</B></DT>
<DD>1.2</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="getCause()"><!-- --></A><H3>
getCause</H3>
<PRE>
public <A HREF="../../java/lang/Throwable.html" title="class in java.lang">Throwable</A> <B>getCause</B>()</PRE>
<DL>
<DD>Returns the the cause of this exception (the exception that was raised
if an error occurred while attempting to load the class; otherwise
<tt>null</tt>).
返回该异常的原因(当试图加载类时发生错误引发该异常;否则为null)。
<P>
<DD><DL>
<DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Throwable.html#getCause()">getCause</A></CODE> in class <CODE><A HREF="../../java/lang/Throwable.html" title="class in java.lang">Throwable</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>the cause of this exception. 异常原因。<DT><B>Since:</B></DT>
<DD>1.4</DD>
</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/ClassNotFoundException.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.4.2</b></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../java/lang/ClassCastException.html" title="class in java.lang"><B>PREV CLASS</B></A>
<A HREF="../../java/lang/CloneNotSupportedException.html" title="class in java.lang"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../index.html" target="_top"><B>FRAMES</B></A>
<A HREF="ClassNotFoundException.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
<font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="../../../relnotes/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to <a href="../../../relnotes/license.html">license terms</a>. Also see the <a href="http://java.sun.com/docs/redist.html">documentation redistribution policy</a>.</font>
</BODY>
</HTML>
本文地址:http://com.8s8s.com/it/it9757.htm