|
| AbstractMethodError |
AbstractMethodError |
| Thrown when an application tries to call an abstract
method. Normally, this error is caught by the compiler. It could occur at run
time only if the callee were modified to make the method or enclosing class abstract
without recompiling both caller and callee. |
| AccessControlException |
AccessControlException |
|
| Applet not inited |
Applet not inited |
- You are using Internet Explorer which has a defective or
missing Java.
- Missing package statement.
- These erroneous Applets will often work with the Java Plug-in, or when run
locally, but will fail with native Javas when run on the web.
- There can also be problems with your jar file having too much or too little
qualification of class names. Your <APPLET CODE=
must have nothing but the class name, without the .class.
- Make sure the case and name exactly match the name of the *.java file, *.class
file, and class name. For a class in a package this would have dots in it, e.g. com.mindprod.mypackage.Myclass,
but it would not have any directory qualification.
- Your CODEBASE= parameters must have an absolute http://-style
reference to the base directory where the code is stored.
- For a local hard disk, the only thing I could get to work reliably on NT with
all browsers and AppletViewers is leaving the CODEBASE
out entirely. You may find for your platform you have to code it something like
this: ///C|//MyDir/ or C:\MyDir\.
- Your ARCHIVE= parameter must have a list of the jar
files, separated by commas. If you have too little or too much qualification, or
if you fail to use the file naming conventions of your server, you will be in
trouble.
- You tried to do something in an unsigned Applet only
signed Applets are allowed to do such as reading
restricted system properties, perhaps indirectly via Color.
getColor.
|
| Application Failed To Start |
The application has failed to start because its side-by-side
configuration is incorrect. |
| Most likely you are using the Microsoft Express C++ compiler to
create your JNI. It links to a run time library which is not present. You need
to put the necessary redistribution support DLLs on the path, or install the
entire C++ run time library on all client machines. The catch is other vendors
may do the same thing, and you can have versioning problems, more commonly known
as DLL hell. Some compilers allow /MT or /LD static linking to create a
standalone DLL that does not require a run time, but Express 2008 will not. |
| ArithmeticException: |
ArithmeticException: / by zero |
| You divided by 0. If it occurred in a paint
method, likely this occurred as a result of creating a Font
with zero height. |
| ArrayIndexOutOfBoundsException |
ArrayIndexOutOfBoundsException |
You have used an array index outside the allowable range. There
may be several array references x[i] in the same line.
Don’t leap to conclusions about which one caused the trouble. Arrays are
indexed from 0 to x.length-1,
not 1 to x.length the way FØRTRAN
programers are used to. When you allocate the array you specify the length
something like this:
int[] x = new int[ 10 ];
|
| ArrayStoreException |
ArrayStoreException |
| The rules of casting arrays and casting the elements of arrays
are subtle. See the gotchas. |
| bad magic number |
Bad magic number |
- The first four bytes of a class file are supposed to say CAFEBABE
in hex. They don’t.
- Most likely the problem is you uploaded your class file to your Web server using
FTP ASCII mode instead of BINARY mode which mangled the class file.
Sun bug number 4151665 : Sometimes when a class is not found it gets reported as corrupt instead.
- Novices get this error when they try to run a program without compiling it first
e.g
java.exe MyClass.java
- If the class file seems ok, consider the possibility some other class file on
the classpath is the one the ClassLoader is looking at.
|
| bad major |
Bad major version number |
| Most likely your class files use a more recent version of Java
than the Java runtime you are using. This most commonly happens with Applets in Internet
Explorer which supports only an ancient version of Java. |
| blank Applet |
Applet works fine run as application, but shows a blank screen without any
error message when run as an Applet. There is not even an Applet loading message. |
| Check the <applet code="com.mindprod.mypackage.Myclass.class"
tag. It is spelled code not class. |
| BoxLayout can’t be shared. |
BoxLayout can’t be shared. |
You wrote something like:
JFrame.this. setLayout
( new BoxLayout( this,
BoxLayout. PAGE_AXIS )
);
instead of:
JFrame.contentPane.setLayout
( new BoxLayout( contentPane,
BoxLayout. PAGE_AXIS )
); |
| can’t create
virtual machine |
Could not create the Java virtual machine |
| You wrote java -xxxx.jar instead of java
-jar xxxx.jar |
| CharConversionException |
CharConversionException |
| Typically you are reading a UTF-8 stream and encounter an
illegal binary pattern that has no meaning. |
| class has wrong version |
class file has wrong version 49.0, should be 48.0 |
| You trying to run class files compiled with JDK version 1.5 on
an older JRE version 1.4. |
| class file contains wrong
class |
class file contains wrong class. Please remove or make sure it appears in
the correct subdirectory of the classpath. |
| If the name of your class is HelloWorld then the name of the
source file must be HelloWorld.java, and case matters.
You also get this error if you have the wrong or missing package statement. You
could also have the source file in the wrong directory if you have a complex
package structure. If your package is called com.mindprod.com.mindprod.mypackage
and your class MyClass, then you had better be in the
root directory and the class file for MyClass hand
better be called MyClass.class and better live in com/mindprod/mypackage,
with matching case! |
| ClassCastException |
ClassCastException |
- You have cast a Class object to a Class
that is not the same class or a super class of the Class
object.
- If the error message complains you have tried to cast class X
to class X, it is complaining that the two different
class Xes belong to different class loaders.
- If the ClassCastException occurs during a sort,
chances are you forgot the implements Comparable.
See the gotchas for details.
- If you write a factory method like this:
protected CameraButton cameraButtonFactory ( int buttonNumber )
{
return new LabelledCameraButton ( buttonNumber, this );
}
and it seems to be producing the wrong kind of objects — ones from the
base class’s version of the method, check the precise spelling and
signature of the method. It had better exactly match the one in the base class.
If it does not exactly match, it will not override. To guard against this error Bali
proposes an explicit overrides keyword.
|
| ClassFormatError |
ClassFormatError |
- You mangled the class file FTP upload by doing it as ASCII instead of binary.
- Further your web server must be configured to send *.class files as binary
rather than ASCII. It needs a MIME configuration entry to define *.class files.
See MIME for details.
- Sometimes it is actually a CLASSPATH problem. It
can’t find the class.
- ClassFormatError: class already loaded. You have a class file twice on the
classpath. It has nothing to do with the DLL already being loaded. Thankfully,
having a DLL still loaded from the last time you ran is not considered an error.
- ClassFormatError: bad major version. Your ancient 1.1 Java runtime does not know
what to do with a program compiled under JDK 1.4..
|
| ClassNotFoundException |
ClassNotFoundException |
- his occurs only at run time. Usually it means a class that was present during
compilation has disappeared, or the classpath has changed so it is no longer
accessible. It could also happen if you dynamically load a class and the class
is not on the classpath.
- Are you spelling the fully qualified class name correctly on your Applet tag.
Case matters. Double check the case of every letter.
- The class itself references another class that can’t be found. Are you
using APIs from versions of Java that aren’t supported by your browser?
- Try specifying CODEBASE="." as an Applet
parameter, to ensure that the browser is looking in the right place.
- Are there packages involved? If so, the Applet class needs to be in a package-appropriate
subdirectory, or better still in a jar, not in the same directory as the HTML
file. If not, you ought to look into putting every class in a some package
before you deploy code; the default (nameless) package is intended only for test
code that won’t be distributed.
- Look at your jar with WinZip. Are all the classes and package names correct with
the correct case? Make sure all the case information is perfect on your jar-building
line.
|
| ConcurrentModificationException |
ConcurrentModificationException |
| You tried to delete or add to a Collection
while you were in the middle of running an Iterator
over it. To get around this, you must remove elements via the Iterator
object using Iterator.remove
rather than the usual Collection.remove.
You can add elements if you use ListIterator.add.
See sample code. |
| Could not find main-class |
Could not find main-class com.mindprod.setclock.SetClock in http://www.mindprod.com/setclock.jar |
| Check that you have the correct package name and class name in
the Java source, in the *.mft file and the *.jnlp
file line <application-desc main-class="com.mindprod.setclock.SetClock"
/> |
| does not contain expected |
myClass.class does not contain myClass as expected, but MyClass. Please
remove the file. Class myClass not found in new. |
- missing caps on new MyClass() reference.
- missing caps on MyClass() obj declaration.
|
| EOFException
in ZIP |
java.io.EOFException: Unexpected end of ZLIB
input stream |
| Try using ZipFile instead of ZipInputStream
to read a zip created by ZipOutputStream. See Zip
for why. |
| ExceptionInInitializerError |
ExceptionInInitializerError |
|
| IllegalAccessError |
IllegalAccessError |
- In Netscape, inner classes can’t seem to access private variables of the
enclosing class. You don’t discover this until run time.
- Failing to use both the <APPLET ARCHIVE= parameter to specify a comma-delimited
list of jar file names and the CODEBASE= parameter in the form of an absolute http://-style
reference to where the jar file is.
- Generally problems with CLASSPATH, CODEBASE, and ARCHIVE.
- Classes in jar have the wrong amount of qualification stored with them.
- Classes in packages are not stored in the correspondingly named directories. See
CLASSPATH and java.exe in the Java glossary for a fuller discussion.
- Using an old library with new code. In the old library a method might be private
where in the new it might be public.
|
| IllegalMonitorStateException |
An IllegalMonitorStateException thrown when an
object’s wait(), notify(),
or notifyAll() method is called from a thread that
does not own the object’s monitor. In other words, the Thread
using these methods must be executing inside a synchronised block locking on the
object whose wait etc. method you are calling. |
| illegal nonvirtual |
Illegal use of nonvirtual function call |
| An inner class is not permitted to call private methods of the
enclosing outer class. It is permitted to call protected methods. This error
message appears in the old Symantec 2.5a Java only
when you have debugging turned off. Normally the compiler should catch this
error, but if it doesn’t it will show up at run time with this strange
error message. |
| Image won’t paint |
Your app uses drawImage, paintComponent
or simply Container.add. Yet nothing appears. |
| See the list of possible causes. |
| Identifier Expected |
When generating Javadoc, you get “Identifier Expected” |
| You are using old version of javadoc.exe
that does not understand the newer Java syntax, or perhaps you are trying to
generate Javadoc before you have a clean compile. |
| Incompatible types |
Incompatible types, found : java.lang.Object, required: java.io.File: for
( File file : wantedFiles
) |
| Make sure you declare your File
collection class with implements Iterable<
File> and its iterator
method with public Iterator<
File> iterator() |
| IncompatibleClassChangeError |
IncompatibleClassChangeError |
- You forgot the static on your main method.
- Any illegal use of a legal class.
- You have made a change to a class and are still referencing it from an another
class by its old signatures. Try deleting all class files and recompiling
everything.
|
| intern overflow |
OutOfMemoryError: string intern table overflow |
| You have too many interned strings.
Some older JVM’s may limit you to 64K Strings, which leaves perhaps 50,000
for your application. |
| InvalidClassException |
java.io.InvalidClassException: local class
incompatible: stream classdesc serialVersionUID = -3714695503693357733. |
Sun’s JDK Platform Guide to InvalidClassException : available:
|
| InvocationTargetException |
InvocationTargetException |
| This is a wrapper exception. You will get one if a method or
constructor you invoke with reflection throws an exception. Because the compiler
cannot analyse methods called through reflection, the reflection runtime wraps
any errors thrown in the called routines in a predictable exception called the InvocationTargetException
which you can catch. Use InvocationTargetException. getCause
and InvocationTargetException. getTargetException
to find more details. |
| IOException |
IOException: invalid header field |
|
| Jar Not Signed With
Same Certificate |
Your JAR-resources in JNLP-File are not signed from the same certificate. |
| You will have to resign all jars mentioned in the JNLP file with
the same certificate. |
| JavaMail obsolete |
You have an obsolete JavaMail or Java Activation Framework jar. |
| Make sure you don’t have more that one mail.jar
or jmf.jar on the classpath/ext directory. |
| JRE not installed |
The application has requested a version of the JRE (version 1.5+) that
currently is not locally installed. |
| If the JRE is not installed, install it.
Normally, you only need the latest version,
1.6.0_10,
none of the older ones. This is a common Java Web Start problem. The JRE is
indeed installed and works fine for non Java Web Start apps. Java Web Start apps
sometimes work fine launched from a browser, but fail when launched from a
desktop shortcut. My theory is somehow the registry or the Java Web Start
development cache gets corrupted in a way that causes Java to use a version of javaws.exe
with the wrong matching directory. There will be at least three copies on your
machine C:\Program Files\java\jre6\bin\javaws.exe,
J:\Program Files\java\jdk1.6.0_10\bin\javaws.exe
and C:\Windows\System32\javaws.exe.
Kludges around the bug include:
- Always launch Java Web Start apps inside a browser.
- Create your own desktop shortcuts with an explicit link to a local copy of the *.jnlp
file and possibly C:\Program Files\java\jre6\bin\javaws.exe
if you are unsure associations are set to use that version of javaws.exe.
- Explicitly launch the JRE javaws.exe with C:\Program Files\java\jre6\bin\javaws.exe
-viewer and use it to launch your apps or create your
shortcuts.
Here is how to fix the problem permanently. Unfortunately, this is a difficult,
time-consuming procedure and does not always work:
- Uninstall any JREs and JDKs
including the SQL database.
- Manually strip out any remaining JRE/JDK files, including those in C:\Windows\System32,
and C:\Users\user\AppData\Roaming\Sun\Java\Deployment\cache.
- Manually delete any references to the JRE/JDK from the registry.
- Remove any Java Web Start desktop shortcuts or menu items.
- run a registry cleaner.
- run NTRegOpt.
- Reboot.
- Reinstall the JDK with associated JRE, making sure you select a drive explicitly
for each of the three pieces, the JDK, the database, and the JRE.
- Fix up the set environment and the ext directories.
|
| load: class not found |
load: class X not found |
| Likely you are using Microsoft’s ancient old JVM in
Internet Explorer that supports only up to Java 1.1.4. Check which version of
Java you are using with Wassup.
Make sure you are using the most recent JRE in C:\Program Files\java\jre6. |
| method not found |
method X not found |
| This is caused by using obsolete jar files. The version of the
class in the jar is missing the method, but at compile time, the java file had
the method. The way to avoid this is to do a clean compile periodically deleting
all class and jar files and rebuilding them. |
|
NoClassDefFoundError |
NoClassDefFoundError |
Detail from The Scream, by Edvard Munch
java.lang.NoClassDefFoundError:
mypackage/MyClass
This one is a bitch to track down. It has so many causes. Java so picky! A
misplaced comma, quote, semicolon, extraneous extension or even the wrong upper/lower
case can derail the whole program. I hope some will implement the NoClassDefFound
Amanuensis to make the problem easier to track down.
- Essentially the problem is the place and name where you put the class file, free-standing
on disk or inside a jar, does match the place and name it should have, based on
the classpath, the package name and the class name. Everything is case sensitive,
and sensitive to the tiniest typo. Unfortunately, there is currently no tool
to tell you where the class should be placed (usually there are several
possibilities) or where it is now.
- You got the class name wrong on the java.exe command
line. It must include the full package name and class separated by dots, without
the .class e.g.
java.exe com.mindprod.converter.Convert
not just the class:
java.exe Convert
Newbies often get in trouble by adding a .java or .class
suffix. In contrast, javac.exe demands the .java
extension.
- You get an error message like this: Exception in thread "main"
java.lang.NoClassDefFoundError: XXX/java. When attempting to compile, you
keyed java.exe XXX.java instead of javac.exe
XXX.java.
- Java can’t find the class mentioned. It is missing from the jar or
classpath. Java may need it because it occurs as a class or superclass in a
serialised ObjectStream or because you called a
method of that class. You don’t find out about the problem at compile time
or even load time. You only find out when you actually go to use that missing
class. The missing class was present when the class referencing it was compiled
(perhaps on somebody else’s machine) but the missing class is no longer
accessible. To fix a vanilla NoClassDefFoundError,
search the all the jar files on your machine for the missing class. Funduc
Search and Replace will do that. If you can’t find it, scour the web
for a download. When you find it, make sure its jar is on the general classpath,
the project classpath, the command line classpath or in the ext
directories of the various JREs you have installed. There will be at least two ext
directories.
- Three diagnostic tools you may find helpful:
- To dump the classpath that you are actually using at some point in your code
insert: You must first determine if the classpath is correct with:
- If you have a jar or more than one class, assign each class to a package!
Package-less classes are for one-shot, single-class throw-away experiments only.
- Then when you are sure the jar or directory you want is truly on the classpath (it
is not sufficient for the directory that the jar is in be on the classpath),
then check the contents of the jar with jarlook to make
sure your package/class is in there, spelled precisely, including case. You can download
jarlook with source.
- download jarcheck as well. It will help
you detect problems with unexpected target versions of class files in your jars.
- Recall that reconstitution of serialized files uses Class.
forName to instantiate all the classes buried in
the files. Genjar or equivalent does not know to
include these classes in your jar. It is up to you to include all the classes
you need manually. You will keep getting the dreaded NoClassDefFoundError
until you have nailed them all.
- Look for a typo in spelling the class file name in the file or in the command
line invoking its main method. Copy/paste to make sure they are absolutely
identical including case.
- Check your classpath. Make sure you used semicolons
or colons as appropriate. Don’t specify null fields in your classpath, e.g.
two semicolons in a row.
- The problem is essentially either the class is not on the classpath or the
classpath is wrong. You must first determine if the classpath is correct with:
- If your program used to work and it “suddenly” stopped working, did
you upgrade your JDK/JRE? If so, you likely forgot to copy over the jars to the C:\Program Files\java\jre6\lib\ext
and C:\Program Files\java\jre6\jre\lib\ext
directories.
- You wrote some code like this:
private static final int a;
static {
a = someMethod();
}
If the class you are loading throws an Exception
during the static initialisation, it will show up
as a ExceptionInInitializerError
rather than the original Exception, which your code
may not be prepared to handle. When your code later goes to use the class, you
will get a NoClassDefFoundException.
- If you see the phrase “wrong name” in the error message, it means
you are not consistently naming the packagename. ClassName
everywhere. Perhaps you left off the packagename, or got the case wrong, or made
a typo in either the package or class name.
- If you have two packages that use classes from each other, each jar must have
all the classes of the other package that it uses, or that it uses indirectly
uses.
- You must put the -classpath option before the class
name on the java command line. To remember the order, you can think of it like
this. Java.exe needs to know the classpath before it
can search for the class.
- You got package name wrong at the top of the source file, or left it out
entirely. It does not match the one when you built the jar. It is case sensitive.
- If this is an Applet, you got the <applet
code="com.mindprod.mypackage.MyClass.class" wrong. Perhaps you
forgot the package part of the name or you forgot the .class.
The package names in the jar may not be right. The <applet
archive="myjar.jar" may not match a jar file containing the
needed class.
- If you use java.exe -jar, it ignores your classpath
environment variable and any -classpath option without
comment! All your classes must be in the jar. This means for example:
java.exe -cp C:\javamail-1.3.3_01\mail.jar -jar bulk.jar
won’t be able to find any of the classes in mail.jar.
You must copy mail.jar to the ext
directory or mention the mail.jar in the manifest Class-Path:
entry.
- Did you remember to include . on your classpath?
- If you got the exception trying to execute a class in a jar, check with WinZip
that the pathnames inside the jar on that class exactly match the package
structure, including case. If you don’t know what I am talking about, see jar
for details. Make sure the class you are trying to call has the expected package
statement. Check the manifest to make sure the fully qualified name of the main-class
is properly specified.
- You are trying to use a program compiled under Java 1.4+ with an old Java 1.1.5
runtime, often the one in Internet Explorer. The old class library is missing
many of the new methods. Any other version mismatch where you run new code on
old runtimes can cause the similar problems. Check the runtime version with:
java.exe -version
java.lang.StringBuilder
is one of the most likely candidates for a method from 1.5+ not available under
earlier JVMs.
- Have you got a simple HelloWorld working yet? If
not, your problem may be in the way you installed the JDK
or JRE. If you have trouble, read up on Getting
Started, javac.exe, java.exe
and classpath.
- Java is case sensitive. Have you got the name of the class spelled exactly the
same way everywhere it is used, including the name of the *.java
file, with class names always starting with a capital letter and package names
pure lower case?
- One of your static initialisers invokes a function
that uses a static field not yet initialised.
- Did you remember to make your kickoff class, the one you mentioned in the java
command line, public?
- Does your main method have signature exactly like this?
public static void main( String[] args )
{
}
- Somehow your runtime is having trouble finding classes it could find at compile
time. Check your CLASSPATH. Make sure all the
classes are available.
- Check your java.exe command line. Your current
directory is crucial. You must specify fully qualified class names, without the .class
extension.
- Consider combining class files in to a single jar file.
Jars cause far less trouble than individual class files, especially when you
export them to a server or someone else’s machine.
- Check that your browser supports jar files. Fortunately, all the modern ones
mentioned under browsers do.
- You can get this error if you try to run an Applet
on an old browser since it will not have the needed classes.
- Watch \ and /. In string
literals \ appears as \\.
- Make sure when developing classes for an extension i.e. class or jar files that
live in the lib/ext/ folder, make sure you do not have
duplicate classes. Classes from extension folders will always be loaded before
any other classpath, therefore making it impossible to test other development
versions not in the extensions folder. Make sure extensions *.jar’s
are complete (i.e., not reliant any additional classes). Make sure the *.jar
in the extensions folder is up to date. Basically only thoroughly-tested, stable
code should live in the extensions folder.
- Have you accidentally used a system package name for your own classes?
- If every program gives NoClassDefFoundErrors, try
uninstalling all Java tools and JDKs, clean out the registry, and then reinstall.
Make sure you have only the latest Java on your machine.
- If your NoClassDefFoundError occurs only
sporadically, here is a possible cause: You are running some classes in a jar
file which is stored on a network mapped drive in MS Windows. Sun keeps the jar
files open in order to re-load classes which haven’t been used in a while,
and occasional network problems will force the jar to close. The JVM doesn’t
know to re-open the jar when the network mapped drive reconnects, and simply
reports that various classes (different each time) no longer exist. The solution
is either make sure the network is reliable, use a network file system which
doesn’t close if drives are temporarily unavailable, or locate all jar
files on local drives.
- If you change the jars used by your JSP code, make sure you manually delete the
generated class files (classes in the WEB-INF tree for
Caucho Resin). The womb won’t be smart enough to do that on its own and
you will get all manner of NoClassDefFoundErrors.
- If you have classes included in your project that don’t live in the same
directory as the project, in Café you must also do a Project
⇒ Options ⇒ Directory ⇒ Classes to include their
directories in the invisible CLASSPATH for the project. Simply including the
java or class files in the project is not sufficient. Other IDEs may have
similar gotchas.
- If your code works then suddenly stops working, chances are you have uninstalled
a JRE/JDK or installed a new one, and the current JDK/JRE does not have the full
complement of jars in the ext directory.Sooner or later you will have to reinstall the JDK/JRE and you will lose your ext
directories.
You can quickly rebuild them if you
maintain a bat file like this and run it after every JRE/JDK install. Adjust the
file to account for where your ext dirs are and where
the jars are you need.
- Sometimes the problem is with your build. Try using ant,
and a script based on one of my examples. Ant has a better chance of getting it
right that some ad hoc build script.
- You overrode JPanel.getParent
or perhaps some other crucial piece of Sun’s code without reproducing its
functionality typically by calling super.xxx().
|
| NoInitialContextException |
NoInitialContextException |
| You did an new javax.naming.InitialContext()
when your program was not running inside a servlet womb which provides the
default Initial context factory. You can provide a factory class by naming it is
a SET environment parameter, or a Java system property java.naming.factory.initial.
Here is some typical code:
|
| NoSuchElementException |
NoSuchElementException |
| You called Iterator.next
when there were no more elements. You must either call isNext
first, or use the for ( Thing:
thing : thingCollection )
syntax which handles it all for you automatically. |
| NoSuchFieldError |
NoSuchFieldError |
| Likely you are mixing an old library with new code or vice versa.
The definitions and references to a class differ in whether they include some
field. If you have source for the libraries, recompile everything to discover
the precise error. If not, check to make sure you are using the most up-to-date
libraries (or ones of the appropriate vintage) and clean compile all your code
making sure the libraries you run with are also on the classpath at compile time.
Compiliation may clear up the problem or at least make it more specific. |
| NoSuchMethodError |
NoSuchMethodError |
| Did you remember to compile? use javac.exe *.java
to compile and java.exe com.mydomain.mypackage.MyClass
to run. Try
del *.class
javac *.java
Did you use a Java 1.5 method with a Java 1.1 runtime? If it is complaining
about the main method, it must have this exact signature.
public static void main( String[] args )
{
} |
| NoSuchProviderException |
javax.mail.NoSuchProviderException |
| Use Transport.sendMessage not Transport.send. |
| NotSerializableException |
NotSerializableException |
You forgot to put implements Serializable
on the class you are doing a writeObject on. Since writeObject
also writes out all the objects pointed to by that object, by the objects those
objects point to, ad infintum, all those classes too must be marked implements
Serializable. Any references to non-serializable
classes must be marked transient. While you are at
it, give each of those classes an explicit version number.
static final long serialVersionUID = 99999999999999L;
Sun’s JDK Platform Guide to NotSerializableException : available:
|
| NTLDR missing |
NTLDR is missing |
- You are trying to boot from a non-system diskette (or disk) in Windows 95/98/ME/NT/W2K/XP/W2K3.
- The crucial loader program used in booting has been deleted from your hard disk.
|
| NullPointerException |
NullPointerException |
- A reference variable is null, when you used it to access a field or method.
- Examine the stack trace to figure out where in the code it happening. That gives
you a clue to get started. You can put some code of the form:
if ( p == null ) System.out.println( "p was null" );
- to narrow it down to the precise variable giving the trouble. Then you have to
sit and think about why that variable is null. The real problem could be
much earlier in the code, and the problem propagated through to the point where
it eventually surfaced as an exception. You must figure out where it was
supposed to be set, and have a look at that code and why it is failing. Most of
the time you simply forgot to initialise. The easiest way to track the causes
down is using a source lever debugger such as Visual
Café or JBuilder. You can trace the flow of execution, or examine the
state of the universe at the time of failure. If you don’t have one,
pepper your code with assertions to track down just what is null, e.g.
ensureNotNull( thing, "thing" );
assert thing != null : "thing is null";
- Your ensureNotNull method might print an error
message if thing is null, then throw a new NullPointerException.
By making ensureNotNull final, and using an if (debug)
inside ensureNotNull, the inline expansions will have no overhead in production,
and you can leave the debugging assertions in place to be reactivated later if
ever needed.
- Most commonly you forgot statements of the form: myArray =
new int[10]; or myThing = new Thing(); See the array
initialisation gotchas. These are the most common of runtime errors.
- You may not call getParameter in the Applet
constructor. Move that code to init.
- Beware having two variable with the same name, one local and one instance, It is
very easy to do inadvertently, and Javac will not
warn you, though Jikes will e.g.
ArrayList thelist = new ArrayList( 149 );
instead of
thelist = new ArrayList( 149 );
You work with the local variable thinking you are working with the instance
variable, and poof, your values are lost as soon as the local goes out of scope,
leaving the instance version null. This is the way I most commonly create
NullPointer exceptions for myself, when I convert a local variable to an
instance one when I have to break a method up that uses the variable and forget
to take out the local declaration.
- Be very careful calling any methods inside your constructors. If subclasses
override them, you will be invoking the subclass’s version, which may be
attempting to use fields that have not been initialised yet. You won’t get
a warning message! The problem usually shows up as puzzling NullPointerExceptions.
The way out is to move code out of the constructor, often to the addNotify
method. However, addNotify can get in analogous
problem to the constructor since it too is overridden, and it may use overridden
methods.
- If the problem is in Sun’s code that you call or indirectly call, look at
the place in your code where you trigger the chain of calls. Insert some debug
code there to examine the parameters and the fields in any objects you pass. If
you can’t track it from that, use a source code debugger like Eclipse that
lets you follow program flow inside Sun’s code.
- Sometimes the problem is redeclaring a local variable with the same name as an
instance variable. You might have initialised one but not the other.
- The Nice language manages to detect NullPointerExceptions
at compile time instead of run time the way Java does.
|
| NumberFormatException |
NumberFormatException |
| The usual problem is leading or trailing spaces on your number.
The sign must come ahead of the number, no commas. Localisation may have an
effect on what constitutes a valid number. Sometimes it can be the number is too
big to fit in the int, long
etc. |
| OptionalDataException |
OptionalDataException |
| Attempting to use readObject on a
stream that does not contain objects, or attempting to read past the end of file. |
| OutOfMemoryError |
OutOfMemoryError |
| You have run out of memory. You have filled up virtual RAM with
objects and the garbage collector can’t free any more RAM. You can expand
the effective size of virtual ram by putting options on the java.exe
command line. See the-Xss64k -Xoss300k -Xms4m and -Xmx10m
options described under java.exe. Perhaps you have
read some ridiculously large number from a DataInputStream
to use an the size of an array. Perhaps you have used a method recursively
without terminating at reasonable depth and filled memory that way.
|
| Pong |
Pong sound |
| IBM Visual Age sometimes makes a noise like an elevator arriving
every time you click anything. No error message is visible anywhere. It means
you are debugging a multi-thread program and a higher priority thread is
blocking the one you want to debug. |
| security violation |
No error while developing. Security Violation in production. |
| Applets can only access the server they were loaded from. |
| signal 10 error |
Unexpected Signal : 10 |
| Signal 10 is a bus error. It’s generally caused by
attempting to perform an unaligned bus operation (for example, reading a long
from an odd address), so it isn’t something that will normally occur in a
pure java application unless theres a bug in the JVM. If you have native code in
your application though, that could be the cause. On some platforms, an
application will get a bus error if its executable file or one of its shared
libraries are replaced while the application is running. |
| StackOverflowError |
StackOverflowError Stack size too small Use java -Xss
to increase default stacksize. |
| These usually happen when you have recursion, a method that
calls itself, perhaps indirectly via a second method. You have simply nested to
deeply. Another source of the problem is calling method x()
or this.x() when you
meant to call super.x(),
usually when inside method x. If you legitimately
overflowed the stack, you may rescue yourself by getting the runtime to allocate
more memory for the stack for each thread with java.exe -Xss128
|
| StreamCorruptedException |
StreamCorruptedException |
The object stream is scrambled. Perhaps you are trying to read
human-readable data, e.g. something that was not prepared with writeObject.
Perhaps you have classes missing or the classes used in the stream are obsolete.
Perhaps you tried to use append mode to tack more onto the end of your stream
file after it was closed and later reopened in append mode. That
does not work.
Sun’s JDK Platform Guide to StreamCorruptedException : available:
|
| StringIndexOutOfBoundsException |
java.lang.StringIndexOutOfBoundsException:
String index out of range |
| The parameters you gave to the substring,
charAt, index or
related String method were outside the range of the
base String, or the start point was after the end
point. See substring gotchas. To track it
down, dump the base String and the indexing
parameters with System.out.
println. |
| TrustProxy |
TrustProxy |
| Applets behind a firewall may not have access to DNS. You must
encode your CODEBASE as an IP instead of a DNS name. |
| unable to load for debugging |
Unable to load MyClass.class for debugging. |
- Symantec support suggests copying all the DLLs in VCP\JAVA\BIN
to VCP\BIN to correct stability problems. If you do
this, all debugging will cease to function. Delete any DLL in VCP\BIN
that also exists is VCP\JAVA\BIN.
- Check that you fully qualified the name of your class with its package name, e.g.
com.mindprod.business.TestDate in the Project section
of Visual Cafe, no trailing ".class" and that the upper and lower case
is precisely correct. Read the section in the glossary on CLASSPATH and under
java.exe on how packages, classnames, the directory structure and the CLASSPATH
all interact. If that does not solve it, I have bad news.
- Windows 95 has the most incredibly inept scheme for dealing with DLLs from
different vendors that just happen to have the same 8+3 name, (even when they
are stored in totally different directories). Whichever application starts first
gets its DLLs installed, and every other app that comes aftward has to use them.
If you start some app before VC, it may load incompatible DLLs. To avoid this,
load VC first. Then the other apps may stop working. Phttt! Mr. Gates has
guaranteed himself a seat in hell for this (and for the confounded registry
where all configuration information for all applications is lumped in one
unrestorable basket). There should be separate system DLLs and application DLLs
with no possibility of DLLs provided by one vendor being foisted on some other.
Try starting Visual Cafe before any other app and keep it running. It stands a
better chance then of getting its own DLLs loaded.
|
| Unable to locate tools.jar |
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.6.0\lib\tools.jar |
| It seems to be looking for tools.jar in the JRE instead of the
JDK. Make sure all the JDK directories contain the expected files, including tools.jar.
I found that uninstalling the JRE and JDK and reinstalling them cleared this up.
Especially for beta softaware you are safer ot uninstall and reinstall rather
than install over top. |
| Unable to open file xxx.exe |
Fatal error (0): Unable to open file xxx.exe |
| In JET when compiling, you forgot to terminate execution of your
app before redoing the compile. |
| unable to run |
Unable to run MyClass.class: Check that you have properly specified name of
the class containing main in your project settings. |
| Your vep project file is not in the same directory with the *.java
and *.class files that compose the class containing Main. |
| UnmarshalException |
java.rmi.UnmarshalException: invalid method hash. |
Some possibilities:
- the receiver does not have the needed class file.
- the receiver and sender have different versions of the class file.
- your stubs are out of date.
- you screwed up something doing RMI. Try a very simple case and get that going,
then gradually add complexity. When it stops working you have a much better idea
where to look for the problem.
|
| UnrecoverableKeyException |
java.security.UnrecoverableKeyException
: Cannot recover key |
| You gave the the wrong password when you accessed the keystore
with KeyStore.getKey. |
|
UnsatisfiedLinkError |
UnsatisfiedLinkError |
| This means you had some trouble loading a library containing
native class implementations.
|
| UnsupportedClassVersionError |
java.lang.UnsupportedClassVersionError:
Unsupported major.minor SomeClass version (nn.n). |
| Try upgrading or reverting your JVM. This is likely a bug —
some native method not prepared to function under the current version. Try
uninstalling all your java, purging the files, then reinstall your JDKs and JREs,
working from oldest to newest. The problem is caused by some sort of clash with
code from one version interacting with code from another. Watch your classpath.
You could have no classes on it for a more advanced JVM
than you are using. Check which version you are using with:
java.exe -version
or use Wassup for more detail. |
| UnsupportedDataTypeException |
javax.activation.UnsupportedDataTypeException:
no object DCH for MIME type text/plain. |
| You have an obsolete JavaMail or Java
Activation Framework jar. |
| VerifyError |
Exception in thread xxx java.lang.VerifyError: Accessing value from
uninitialized register 2. |
| This is a Sun
compiler bug. It comes from redefining a local variable. Just use two
different names. Could come from other compiler bugs. Try using a different
compiler. It can also come from using Outer.this from
a non-inner class. In JDK 1.4.2+, the compiler should detect the problem rather
than runtime. |
| wrong name |
This is a NoClassDefFoundError where you
got package name wrong at the top of the source file. It does not match the one
when you built the jar. It is case sensitive. |
|
| wrong version |
class file has wrong version 48.0, should be 47.0 |
| You have partly a JDK 1.4 and partly an earlier version of Java
installed. Check out each copy of java.exe and with
the -version option. If necessary uninstall all JDKs
and JREs, prune the registry of references to Java,
prune the hard disk of java directories and reinstall from scratch. Watch out
for any JDKs that came embedded with an IDE. Watch out specially for the C:\WINNT\system32\java.exe.
It too should be 1.4. You may have the rt.jar file
from an different version. |
| ZipException |
java.util.zip.ZipException: The system cannot
find the file specified. |
| Usually the zip file in question is the distribution jar
containing your class files and resources. For some reason it can’t be
found. You may have misspelled it or used the wrong syntax to specify it.
|